Permalink
Browse files

Update jquery.marquee.min.js

  • Loading branch information...
1 parent 95ab0d5 commit ec3ced4944bf4f1273c4e32edb0ab1d42ae06860 @aamirafridi committed on GitHub Aug 29, 2016
Showing with 11 additions and 1 deletion.
  1. +11 −1 jquery.marquee.min.js
View
@@ -2,4 +2,14 @@
* jQuery.marquee - scrolling text like old marquee element
* @author Aamir Afridi - aamirafridi(at)gmail(dot)com / http://aamirafridi.com/jquery/jquery-marquee-plugin
*/
-!function(e){e.fn.marquee=function(t){return this.each(function(){var i,a,n,r,s,o=e.extend({},e.fn.marquee.defaults,t),u=e(this),d=3,p="animation-play-state",l=!1,c=function(e,t,i){for(var a=["webkit","moz","MS","o",""],n=0;n<a.length;n++)a[n]||(t=t.toLowerCase()),e.addEventListener(a[n]+t,i,!1)},f=function(e){var t=[];for(var i in e)e.hasOwnProperty(i)&&t.push(i+":"+e[i]);return t.push(),"{"+t.join(",")+"}"},m=function(){u.timer=setTimeout(B,o.delayBeforeStart)},g={pause:function(){l&&o.allowCss3Support?i.css(p,"paused"):e.fn.pause&&i.pause(),u.data("runningStatus","paused"),u.trigger("paused")},resume:function(){l&&o.allowCss3Support?i.css(p,"running"):e.fn.resume&&i.resume(),u.data("runningStatus","resumed"),u.trigger("resumed")},toggle:function(){g["resumed"==u.data("runningStatus")?"pause":"resume"]()},destroy:function(){clearTimeout(u.timer),u.find("*").andSelf().unbind(),u.html(u.find(".js-marquee:first").html())}};if("string"==typeof t)return void(e.isFunction(g[t])&&(i||(i=u.find(".js-marquee-wrapper")),u.data("css3AnimationIsSupported")===!0&&(l=!0),g[t]()));var h;e.each(o,function(e,t){if(h=u.attr("data-"+e),"undefined"!=typeof h){switch(h){case"true":h=!0;break;case"false":h=!1}o[e]=h}}),o.duration=o.speed||o.duration,r="up"==o.direction||"down"==o.direction,o.gap=o.duplicated?parseInt(o.gap):0,u.wrapInner('<div class="js-marquee"></div>');var v=u.find(".js-marquee").css({"margin-right":o.gap,"float":"left"});if(o.duplicated&&v.clone(!0).appendTo(u),u.wrapInner('<div style="width:100000px" class="js-marquee-wrapper"></div>'),i=u.find(".js-marquee-wrapper"),r){var y=u.height();i.removeAttr("style"),u.height(y),u.find(".js-marquee").css({"float":"none","margin-bottom":o.gap,"margin-right":0}),o.duplicated&&u.find(".js-marquee:last").css({"margin-bottom":0});var x=u.find(".js-marquee:first").height()+o.gap;o.startVisible&&!o.duplicated?(o._completeDuration=(parseInt(x,10)+parseInt(y,10))/parseInt(y,10)*o.duration,o.duration=parseInt(x,10)/parseInt(y,10)*o.duration):o.duration=(parseInt(x,10)+parseInt(y,10))/parseInt(y,10)*o.duration}else s=u.find(".js-marquee:first").width()+o.gap,a=u.width(),o.startVisible&&!o.duplicated?(o._completeDuration=(parseInt(s,10)+parseInt(a,10))/parseInt(a,10)*o.duration,o.duration=parseInt(s,10)/parseInt(a,10)*o.duration):o.duration=(parseInt(s,10)+parseInt(a,10))/parseInt(a,10)*o.duration;if(o.duplicated&&(o.duration=o.duration/2),o.allowCss3Support){var I=document.body||document.createElement("div"),b="marqueeAnimation-"+Math.floor(1e7*Math.random()),S="Webkit Moz O ms Khtml".split(" "),w="animation",q="",j="";if(I.style.animation&&(j="@keyframes "+b+" ",l=!0),l===!1)for(var C=0;C<S.length;C++)if(void 0!==I.style[S[C]+"AnimationName"]){var V="-"+S[C].toLowerCase()+"-";w=V+w,p=V+p,j="@"+V+"keyframes "+b+" ",l=!0;break}l&&(q=b+" "+o.duration/1e3+"s "+o.delayBeforeStart/1e3+"s infinite "+o.css3easing,u.data("css3AnimationIsSupported",!0))}var A=function(){i.css("margin-top","up"==o.direction?y+"px":"-"+x+"px")},k=function(){i.css("margin-left","left"==o.direction?a+"px":"-"+s+"px")};o.duplicated?(r?o.startVisible?i.css("margin-top",0):i.css("margin-top","up"==o.direction?y+"px":"-"+(2*x-o.gap)+"px"):o.startVisible?i.css("margin-left",0):i.css("margin-left","left"==o.direction?a+"px":"-"+(2*s-o.gap)+"px"),o.startVisible||(d=1)):o.startVisible?d=2:r?A():k();var B=function(){if(o.duplicated&&(1===d?(o._originalDuration=o.duration,r?o.duration="up"==o.direction?o.duration+y/(x/o.duration):2*o.duration:o.duration="left"==o.direction?o.duration+a/(s/o.duration):2*o.duration,q&&(q=b+" "+o.duration/1e3+"s "+o.delayBeforeStart/1e3+"s "+o.css3easing),d++):2===d&&(o.duration=o._originalDuration,q&&(b+="0",j=e.trim(j)+"0 ",q=b+" "+o.duration/1e3+"s 0s infinite "+o.css3easing),d++)),r?o.duplicated?(d>2&&i.css("margin-top","up"==o.direction?0:"-"+x+"px"),n={"margin-top":"up"==o.direction?"-"+x+"px":0}):o.startVisible?2===d?(q&&(q=b+" "+o.duration/1e3+"s "+o.delayBeforeStart/1e3+"s "+o.css3easing),n={"margin-top":"up"==o.direction?"-"+x+"px":y+"px"},d++):3===d&&(o.duration=o._completeDuration,q&&(b+="0",j=e.trim(j)+"0 ",q=b+" "+o.duration/1e3+"s 0s infinite "+o.css3easing),A()):(A(),n={"margin-top":"up"==o.direction?"-"+i.height()+"px":y+"px"}):o.duplicated?(d>2&&i.css("margin-left","left"==o.direction?0:"-"+s+"px"),n={"margin-left":"left"==o.direction?"-"+s+"px":0}):o.startVisible?2===d?(q&&(q=b+" "+o.duration/1e3+"s "+o.delayBeforeStart/1e3+"s "+o.css3easing),n={"margin-left":"left"==o.direction?"-"+s+"px":a+"px"},d++):3===d&&(o.duration=o._completeDuration,q&&(b+="0",j=e.trim(j)+"0 ",q=b+" "+o.duration/1e3+"s 0s infinite "+o.css3easing),k()):(k(),n={"margin-left":"left"==o.direction?"-"+s+"px":a+"px"}),u.trigger("beforeStarting"),l){i.css(w,q);var t=j+" { 100% "+f(n)+"}",p=i.find("style");0!==p.length?p.filter(":last").html(t):i.append("<style>"+t+"</style>"),c(i[0],"AnimationIteration",function(){u.trigger("finished")}),c(i[0],"AnimationEnd",function(){B(),u.trigger("finished")})}else i.animate(n,o.duration,o.easing,function(){u.trigger("finished"),o.pauseOnCycle?m():B()});u.data("runningStatus","resumed")};u.bind("pause",g.pause),u.bind("resume",g.resume),o.pauseOnHover&&u.bind("mouseenter mouseleave",g.toggle),l&&o.allowCss3Support?B():m()})},e.fn.marquee.defaults={allowCss3Support:!0,css3easing:"linear",easing:"linear",delayBeforeStart:1e3,direction:"left",duplicated:!1,duration:5e3,gap:20,pauseOnCycle:!1,pauseOnHover:!1,startVisible:!1}}(jQuery);
+(function(f){f.fn.marquee=function(x){return this.each(function(){var a=f.extend({},f.fn.marquee.defaults,x),b=f(this),c,h,t,u,k,e=3,y="animation-play-state",n=!1,E=function(a,b,c){for(var e=["webkit","moz","MS","o",""],d=0;d<e.length;d++)e[d]||(b=b.toLowerCase()),a.addEventListener(e[d]+b,c,!1)},F=function(a){var b=[],c;for(c in a)a.hasOwnProperty(c)&&b.push(c+":"+a[c]);b.push();return"{"+b.join(",")+"}"},p={pause:function(){n&&a.allowCss3Support?c.css(y,"paused"):f.fn.pause&&c.pause();b.data("runningStatus",
+"paused");b.trigger("paused")},resume:function(){n&&a.allowCss3Support?c.css(y,"running"):f.fn.resume&&c.resume();b.data("runningStatus","resumed");b.trigger("resumed")},toggle:function(){p["resumed"==b.data("runningStatus")?"pause":"resume"]()},destroy:function(){clearTimeout(b.timer);b.find("*").andSelf().unbind();b.html(b.find(".js-marquee:first").html())}};if("string"===typeof x)f.isFunction(p[x])&&(c||(c=b.find(".js-marquee-wrapper")),!0===b.data("css3AnimationIsSupported")&&(n=!0),p[x]());else{var v;
+f.each(a,function(c,d){v=b.attr("data-"+c);if("undefined"!==typeof v){switch(v){case "true":v=!0;break;case "false":v=!1}a[c]=v}});a.speed&&(a.duration=a.speed*parseInt(b.width(),10));u="up"==a.direction||"down"==a.direction;a.gap=a.duplicated?parseInt(a.gap):0;b.wrapInner('<div class="js-marquee"></div>');var l=b.find(".js-marquee").css({"margin-right":a.gap,"float":"left"});a.duplicated&&l.clone(!0).appendTo(b);b.wrapInner('<div style="width:100000px" class="js-marquee-wrapper"></div>');c=b.find(".js-marquee-wrapper");
+if(u){var m=b.height();c.removeAttr("style");b.height(m);b.find(".js-marquee").css({"float":"none","margin-bottom":a.gap,"margin-right":0});a.duplicated&&b.find(".js-marquee:last").css({"margin-bottom":0});var q=b.find(".js-marquee:first").height()+a.gap;a.startVisible&&!a.duplicated?(a._completeDuration=(parseInt(q,10)+parseInt(m,10))/parseInt(m,10)*a.duration,a.duration*=parseInt(q,10)/parseInt(m,10)):a.duration*=(parseInt(q,10)+parseInt(m,10))/parseInt(m,10)}else k=b.find(".js-marquee:first").width()+
+a.gap,h=b.width(),a.startVisible&&!a.duplicated?(a._completeDuration=(parseInt(k,10)+parseInt(h,10))/parseInt(h,10)*a.duration,a.duration*=parseInt(k,10)/parseInt(h,10)):a.duration*=(parseInt(k,10)+parseInt(h,10))/parseInt(h,10);a.duplicated&&(a.duration/=2);if(a.allowCss3Support){var l=document.body||document.createElement("div"),g="marqueeAnimation-"+Math.floor(1E7*Math.random()),A=["Webkit","Moz","O","ms","Khtml"],B="animation",d="",r="";l.style.animation&&(r="@keyframes "+g+" ",n=!0);if(!1===
+n)for(var z=0;z<A.length;z++)if(void 0!==l.style[A[z]+"AnimationName"]){l="-"+A[z].toLowerCase()+"-";B=l+B;y=l+y;r="@"+l+"keyframes "+g+" ";n=!0;break}n&&(d=g+" "+a.duration/1E3+"s "+a.delayBeforeStart/1E3+"s infinite "+a.css3easing,b.data("css3AnimationIsSupported",!0))}var C=function(){c.css("margin-top","up"==a.direction?m+"px":"-"+q+"px")},D=function(){c.css("margin-left","left"==a.direction?h+"px":"-"+k+"px")};a.duplicated?(u?a.startVisible?c.css("margin-top",0):c.css("margin-top","up"==a.direction?
+m+"px":"-"+(2*q-a.gap)+"px"):a.startVisible?c.css("margin-left",0):c.css("margin-left","left"==a.direction?h+"px":"-"+(2*k-a.gap)+"px"),a.startVisible||(e=1)):a.startVisible?e=2:u?C():D();var w=function(){a.duplicated&&(1===e?(a._originalDuration=a.duration,a.duration=u?"up"==a.direction?a.duration+m/(q/a.duration):2*a.duration:"left"==a.direction?a.duration+h/(k/a.duration):2*a.duration,d&&(d=g+" "+a.duration/1E3+"s "+a.delayBeforeStart/1E3+"s "+a.css3easing),e++):2===e&&(a.duration=a._originalDuration,
+d&&(g+="0",r=f.trim(r)+"0 ",d=g+" "+a.duration/1E3+"s 0s infinite "+a.css3easing),e++));u?a.duplicated?(2<e&&c.css("margin-top","up"==a.direction?0:"-"+q+"px"),t={"margin-top":"up"==a.direction?"-"+q+"px":0}):a.startVisible?2===e?(d&&(d=g+" "+a.duration/1E3+"s "+a.delayBeforeStart/1E3+"s "+a.css3easing),t={"margin-top":"up"==a.direction?"-"+q+"px":m+"px"},e++):3===e&&(a.duration=a._completeDuration,d&&(g+="0",r=f.trim(r)+"0 ",d=g+" "+a.duration/1E3+"s 0s infinite "+a.css3easing),C()):(C(),t={"margin-top":"up"==
+a.direction?"-"+c.height()+"px":m+"px"}):a.duplicated?(2<e&&c.css("margin-left","left"==a.direction?0:"-"+k+"px"),t={"margin-left":"left"==a.direction?"-"+k+"px":0}):a.startVisible?2===e?(d&&(d=g+" "+a.duration/1E3+"s "+a.delayBeforeStart/1E3+"s "+a.css3easing),t={"margin-left":"left"==a.direction?"-"+k+"px":h+"px"},e++):3===e&&(a.duration=a._completeDuration,d&&(g+="0",r=f.trim(r)+"0 ",d=g+" "+a.duration/1E3+"s 0s infinite "+a.css3easing),D()):(D(),t={"margin-left":"left"==a.direction?"-"+k+"px":
+h+"px"});b.trigger("beforeStarting");if(n){c.css(B,d);var l=r+" { 100% "+F(t)+"}",p=c.find("style");0!==p.length?p.filter(":last").html(l):c.append("<style>"+l+"</style>");E(c[0],"AnimationIteration",function(){b.trigger("finished")});E(c[0],"AnimationEnd",function(){w();b.trigger("finished")})}else c.animate(t,a.duration,a.easing,function(){b.trigger("finished");a.pauseOnCycle?b.timer=setTimeout(w,a.delayBeforeStart):w()});b.data("runningStatus","resumed")};b.bind("pause",p.pause);b.bind("resume",
+p.resume);a.pauseOnHover&&b.bind("mouseenter mouseleave",p.toggle);n&&a.allowCss3Support?w():b.timer=setTimeout(w,a.delayBeforeStart)}})};f.fn.marquee.defaults={allowCss3Support:!0,css3easing:"linear",easing:"linear",delayBeforeStart:1E3,direction:"left",duplicated:!1,duration:5E3,gap:20,pauseOnCycle:!1,pauseOnHover:!1,startVisible:!1}})(jQuery);

0 comments on commit ec3ced4

Please sign in to comment.