forked from aamirafridi/jQuery.Marquee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.marquee.min.js
1 lines (1 loc) · 1.92 KB
/
jquery.marquee.min.js
1
!function(a){var b={init:function(b){return this.each(function(){var e,c=a(this),f=c.data("marquee");if("undefined"==typeof f){var g={speed:1e4,gap:20,delayBeforeStart:1e3,direction:"left",postAnimationPause:0};f=a.extend({},g,b),c.data("marquee",f)}else f=a.extend({},f,b);c.wrapInner('<div class="js-marquee"></div>'),c.find(".js-marquee").css({"margin-right":f.gap,float:"left"}).clone().appendTo(c),c.wrapInner('<div style="width:100000px" class="js-marquee-wrapper"></div>'),e=c.find(".js-marquee:first").width()+f.gap,f.elWidth=e,c.data("marquee",f),setTimeout(function(){c.marquee("zero"),c.marquee("start")},f.delayBeforeStart)})},get:function(b){return a(this).find(".js-marquee-wrapper")},destroy:function(b){return a(this).each(function(){a(this).removeData("marquee")})},start:function(b){$this=a(this);var d=$this.data("marquee");$el=$this.marquee("get"),c($el,d)},stop:function(b){var c=a(this).find(".js-marquee-wrapper");c.clearQueue(),c.stop()},reset:function(b){$this=a(this),$this.marquee("stop"),$this.marquee("zero"),$this.marquee("start")},revert:function(b){$this=a(this);var c=$this.data("marquee");c.direction="left"==c.direction?"right":"left",$this.marquee("stop"),$this.marquee("start")},zero:function(b){$this=a(this);var c=$this.marquee("get"),d=$this.data("marquee");c.css("margin-left","left"==d.direction?0:"-"+d.elWidth+"px")}},c=function(a,b){var d=b.elWidth?b.elWidth:$this.find(".js-marquee:first").width()+b.gap,e="left"==b.direction?d+parseInt(a.css("margin-left")):-1*parseInt(a.css("margin-left")),f=e/d;f=f>0?f:1,a.animate({"margin-left":"left"==b.direction?"-"+d+"px":0},b.speed*f,"linear",function(){a.css("margin-left","left"==b.direction?0:"-"+d+"px"),setTimeout(function(){c(a,b)},b.postAnimationPause)})};a.fn.marquee=function(c){return b[c]?b[c].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof c&&c?void a.error("Method "+c+" does not exist on jQuery.marquee"):b.init.apply(this,arguments)}}(jQuery);