/** * jQuery.hoverPlay * @version 1.1 * @author biohzrdmx * @requires jQuery 1.8+ * @license MIT * @copyright Copyright © 2018 biohzrdmx. All rights reserved. */ ;!function(a){a.hoverPlay={},a.fn.hoverPlay=function(e){if(!this.length)return this;var t=a.extend(!0,{},a.hoverPlay.defaults,e);return this.each(function(){var e=a(this),o=e.get(0);"function"==typeof o.play&&(o.controls=!1,o.loop=!0,e.on("mouseover",function(){var a=e.data("hoverPlayTimeout");a||(a=setTimeout(function(){e.data("hoverPlayTimeout",null),t.callbacks.play(e,o),e.trigger("hoverPlay")},t.playDelay),e.data("hoverPlayTimeout",a))}).on("mouseout",function(){var a=e.data("hoverPlayTimeout");a&&(clearTimeout(a),e.data("hoverPlayTimeout",null)),setTimeout(function(){t.callbacks.pause(e,o),e.trigger("hoverPause")},t.pauseDelay)}).on("click",function(a){return t.callbacks.click(e,o,a)}))}),this},a.hoverPlay.defaults={playDelay:350,pauseDelay:0,callbacks:{play:function(a,e){e.play()},pause:function(a,e){e.pause()},click:function(a,e,t){t.preventDefault()}}},jQuery(document).ready(function(a){a("[data-play=hover]").hoverPlay()})}(jQuery);