diff --git a/source/jquery.slides.coffee b/source/jquery.slides.coffee index cdeb9ba..f020cd4 100755 --- a/source/jquery.slides.coffee +++ b/source/jquery.slides.coffee @@ -393,6 +393,9 @@ @data = $.data this touches = e.originalEvent.touches[0] + if @options.play.pauseOnHover + @_pause() + # Setup the next and previous slides for swiping @_setuptouch() @@ -413,6 +416,9 @@ @data = $.data this touches = e.originalEvent.touches[0] + if @options.play.pauseOnHover + @_restart() + # Define slides control slidesControl = $(".slidesjs-control", $element) @@ -515,18 +521,11 @@ # Stop/pause slideshow on mouse enter slidesContainer.bind "mouseenter", => - clearTimeout @data.restartDelay - $.data this, "restartDelay", null - @stop() + @_pause() # Play slideshow on mouse leave slidesContainer.bind "mouseleave", => - if @options.play.restartDelay - $.data this, "restartDelay", setTimeout ( => - @play(true) - ), @options.play.restartDelay - else - @play() + @_restart() $.data this, "playing", true @@ -559,6 +558,23 @@ $(".slidesjs-stop", $element).hide() $(".slidesjs-play", $element).show() + # @_pause() + # pause the slideshow + Plugin::_pause = -> + clearTimeout @data.restartDelay + $.data this, "restartDelay", null + @stop() + + # @_restart() + # restart the slideshow + Plugin::_restart = -> + if @options.play.restartDelay + $.data this, "restartDelay", setTimeout ( => + @play(true) + ), @options.play.restartDelay + else + @play() + # @_slide() # CSS3 and JavaScript slide animations Plugin::_slide = (number) -> diff --git a/source/jquery.slides.js b/source/jquery.slides.js index f5b2d27..1a459bf 100644 --- a/source/jquery.slides.js +++ b/source/jquery.slides.js @@ -1,6 +1,5 @@ -// Generated by CoffeeScript 1.6.1 +// Generated by CoffeeScript 1.6.3 (function() { - (function($, window, document) { var Plugin, defaults, pluginName; pluginName = "slidesjs"; @@ -41,7 +40,6 @@ } }; Plugin = (function() { - function Plugin(element, options) { this.element = element; this.options = $.extend(true, {}, defaults, options); @@ -309,6 +307,9 @@ $element = $(this.element); this.data = $.data(this); touches = e.originalEvent.touches[0]; + if (this.options.play.pauseOnHover) { + this._pause(); + } this._setuptouch(); $.data(this, "touchtimer", Number(new Date())); $.data(this, "touchstartx", touches.pageX); @@ -321,6 +322,9 @@ $element = $(this.element); this.data = $.data(this); touches = e.originalEvent.touches[0]; + if (this.options.play.pauseOnHover) { + this._restart(); + } slidesControl = $(".slidesjs-control", $element); if (slidesControl.position().left > this.options.width * 0.5 || slidesControl.position().left > this.options.width * 0.1 && (Number(new Date()) - this.data.touchtimer < 250)) { $.data(this, "direction", "previous"); @@ -391,16 +395,10 @@ if (this.options.play.pauseOnHover) { slidesContainer.unbind(); slidesContainer.bind("mouseenter", function() { - return _this.stop(); + return _this._pause(); }); slidesContainer.bind("mouseleave", function() { - if (_this.options.play.restartDelay) { - return $.data(_this, "restartDelay", setTimeout((function() { - return _this.play(true); - }), _this.options.play.restartDelay)); - } else { - return _this.play(); - } + return _this._restart(); }); } $.data(this, "playing", true); @@ -427,6 +425,21 @@ return $(".slidesjs-play", $element).show(); } }; + Plugin.prototype._pause = function() { + clearTimeout(this.data.restartDelay); + $.data(this, "restartDelay", null); + return this.stop(); + }; + Plugin.prototype._restart = function() { + var _this = this; + if (this.options.play.restartDelay) { + return $.data(this, "restartDelay", setTimeout((function() { + return _this.play(true); + }), this.options.play.restartDelay)); + } else { + return this.play(); + } + }; Plugin.prototype._slide = function(number) { var $element, currentSlide, direction, duration, next, prefix, slidesControl, timing, transform, value, _this = this; diff --git a/source/jquery.slides.min.js b/source/jquery.slides.min.js index 427e06b..85d1308 100644 --- a/source/jquery.slides.min.js +++ b/source/jquery.slides.min.js @@ -4,4 +4,4 @@ Updated: June 26th, 2013 Apache License: http://www.apache.org/licenses/LICENSE-2.0 */ -(function(){(function(e,t,n){var r,i,s;s="slidesjs";i={width:940,height:528,start:1,navigation:{active:!0,effect:"slide"},pagination:{active:!0,effect:"slide"},play:{active:!1,effect:"slide",interval:5e3,auto:!1,swap:!0,pauseOnHover:!1,restartDelay:2500},effect:{slide:{speed:500},fade:{speed:300,crossfade:!0}},callback:{loaded:function(){},start:function(){},complete:function(){}}};r=function(){function t(t,n){this.element=t;this.options=e.extend(!0,{},i,n);this._defaults=i;this._name=s;this.init()}return t}();r.prototype.init=function(){var n,r,i,s,o,u,a=this;n=e(this.element);this.data=e.data(this);e.data(this,"animating",!1);e.data(this,"total",n.children().not(".slidesjs-navigation",n).length);e.data(this,"current",this.options.start-1);e.data(this,"vendorPrefix",this._getVendorPrefix());if(typeof TouchEvent!="undefined"){e.data(this,"touch",!0);this.options.effect.slide.speed=this.options.effect.slide.speed/2}n.css({overflow:"hidden"});n.slidesContainer=n.children().not(".slidesjs-navigation",n).wrapAll("
",n).parent().css({overflow:"hidden",position:"relative"});e(".slidesjs-container",n).wrapInner("
",n).children();e(".slidesjs-control",n).css({position:"relative",left:0});e(".slidesjs-control",n).children().addClass("slidesjs-slide").css({position:"absolute",top:0,left:0,width:"100%",zIndex:0,display:"none",webkitBackfaceVisibility:"hidden"});e.each(e(".slidesjs-control",n).children(),function(t){var n;n=e(this);return n.attr("slidesjs-index",t)});if(this.data.touch){e(".slidesjs-control",n).on("touchstart",function(e){return a._touchstart(e)});e(".slidesjs-control",n).on("touchmove",function(e){return a._touchmove(e)});e(".slidesjs-control",n).on("touchend",function(e){return a._touchend(e)})}n.fadeIn(0);this.update();this.data.touch&&this._setuptouch();e(".slidesjs-control",n).children(":eq("+this.data.current+")").eq(0).fadeIn(0,function(){return e(this).css({zIndex:10})});if(this.options.navigation.active){o=e("",{"class":"slidesjs-previous slidesjs-navigation",href:"#",title:"Previous",text:"Previous"}).appendTo(n);r=e("",{"class":"slidesjs-next slidesjs-navigation",href:"#",title:"Next",text:"Next"}).appendTo(n)}e(".slidesjs-next",n).click(function(e){e.preventDefault();a.stop(!0);return a.next(a.options.navigation.effect)});e(".slidesjs-previous",n).click(function(e){e.preventDefault();a.stop(!0);return a.previous(a.options.navigation.effect)});if(this.options.play.active){s=e("",{"class":"slidesjs-play slidesjs-navigation",href:"#",title:"Play",text:"Play"}).appendTo(n);u=e("",{"class":"slidesjs-stop slidesjs-navigation",href:"#",title:"Stop",text:"Stop"}).appendTo(n);s.click(function(e){e.preventDefault();return a.play(!0)});u.click(function(e){e.preventDefault();return a.stop(!0)});this.options.play.swap&&u.css({display:"none"})}if(this.options.pagination.active){i=e("