-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwalt.min.js
14 lines (14 loc) · 4.96 KB
/
walt.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*!
* WaltJS 2.0
* @author Andy Mikulski <[email protected]>
*/
(function(d,k,f,g,m){d.Walt=function(d){function d(){this.settings=this.defaults;this.onBefores=[];this.onAfters=[];this.onBeforeEaches=[];this.onAfterEaches=[];return this}function l(a){a.indexOf&&(-1<a.indexOf("ms")||-1<a.indexOf("s"))||(a+="ms");return a}function h(a){return{"-webkit-animation":a||"",animation:a||""}}d.prototype={defaults:{element:f(k.body||k.documentElement),animation:"fadeIn",delay:"0s",duration:"1s",count:1,fill:"both",direction:"normal",timing:"ease",state:"paused"},target:function(a){a=
a instanceof f?a:f(a);this.settings.element=a;return this},children:function(a){this.settings.element=a?this.settings.element.find(a):this.settings.element.children();return this},name:function(a){this.settings.animation=a;return this},fill:function(a){this.settings.fill=a;return this},direction:function(a){this.settings.direction=a;return this},timing:function(a){this.settings.timing=a;return this},duration:function(a){this.settings.duration=l(a);return this},delay:function(a){this.settings.delay=
l(a);return this},count:function(a){this.settings.count=a;return this},before:function(a){var b=this;b.onBefores.push(function(c){a&&a(b.settings.element,b.settings);c&&c(null,null)});return b},beforeEach:function(a){var b=this;b.onBeforeEaches.push(function(c){a&&a(b.settings.element,b.settings);c&&c(null,null)});return b},after:function(a){var b=this;b.onAfters.push(function(c){a&&a(b.settings.element,b.settings);c&&c(null,null)});return b},then:function(a){return this.after(a)},done:function(a){return this.after(a)},
afterEach:function(a){var b=this;b.onAfterEaches.push(function(c){a&&a(b.settings.element,b.settings);c&&c(null,null)});return b},pause:function(){this.settings.state="paused";return this},play:function(){this.settings.state="running";return this},resume:function(){this.settings.state="running";return this},animate:function(){g.parallel(this.onBefores,this._executeAnim.bind(this));return this},fork:function(a){var b=new d,c;for(c in this)if(a||"onBefores"!==c&&"onAfters"!==c&&"onBeforeEaches"!==c&&
"onAfterEaches"!==c)b[c]=this[c];return b},_executeAnim:function(){this.play();var a=this.settings,a=a.animation+" "+a.duration+" "+a.timing+" "+a.delay+" "+a.count+" "+a.direction+" "+a.fill+" "+a.state;this.animCount=0;this.animMax=this.settings.element.length;this.settings.element.unbind("animationend.walt").on("animationend.walt",this._onAnimEndEvent.bind(this));this.settings.element.css(h(a));return this},_onAnimEndEvent:function(a){var b=this;a=f(a.currentTarget);a.unbind("animationend.walt");
a.css(h());b.animCount+=1;g.parallel(b.onAfterEaches,function(){b.animCount>b.animMax&&b._onAnimComplete()});return b},_onAnimComplete:function(){var a=this;g.parallel(a.onAfters,function(){delete a.animCount;delete a.animMax;a.settings.element.css(h())});return a},easings:{linear:"cubic-bezier(0.250, 0.250, 0.750, 0.750)",ease:"cubic-bezier(0.250, 0.100, 0.250, 1.000)",easeIn:"cubic-bezier(0.420, 0.000, 1.000, 1.000)",easeOut:"cubic-bezier(0.000, 0.000, 0.580, 1.000)",easeInOut:"cubic-bezier(0.420, 0.000, 0.580, 1.000)",
easeInQuad:"cubic-bezier(0.550, 0.085, 0.680, 0.530)",easeInCubic:"cubic-bezier(0.550, 0.055, 0.675, 0.190)",easeInQuart:"cubic-bezier(0.895, 0.030, 0.685, 0.220)",easeInQuint:"cubic-bezier(0.755, 0.050, 0.855, 0.060)",easeInSine:"cubic-bezier(0.470, 0.000, 0.745, 0.715)",easeInExpo:"cubic-bezier(0.950, 0.050, 0.795, 0.035)",easeInCirc:"cubic-bezier(0.600, 0.040, 0.980, 0.335)",easeInBack:"cubic-bezier(0.600, -0.280, 0.735, 0.045)",easeOutQuad:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",easeOutCubic:"cubic-bezier(0.215, 0.610, 0.355, 1.000)",
easeOutQuart:"cubic-bezier(0.165, 0.840, 0.440, 1.000)",easeOutQuint:"cubic-bezier(0.230, 1.000, 0.320, 1.000)",easeOutSine:"cubic-bezier(0.390, 0.575, 0.565, 1.000)",easeOutExpo:"cubic-bezier(0.190, 1.000, 0.220, 1.000)",easeOutCirc:"cubic-bezier(0.075, 0.820, 0.165, 1.000)",easeOutBack:"cubic-bezier(0.175, 0.885, 0.320, 1.275)",easeInOutQuad:"cubic-bezier(0.455, 0.030, 0.515, 0.955)",easeInOutCubic:"cubic-bezier(0.645, 0.045, 0.355, 1.000)",easeInOutQuart:"cubic-bezier(0.770, 0.000, 0.175, 1.000)",
easeInOutQuint:"cubic-bezier(0.860, 0.000, 0.070, 1.000)",easeInOutSine:"cubic-bezier(0.445, 0.050, 0.550, 0.950)",easeInOutExpo:"cubic-bezier(1.000, 0.000, 0.000, 1.000)",easeInOutCirc:"cubic-bezier(0.785, 0.135, 0.150, 0.860)",easeInOutBack:"cubic-bezier(0.680, -0.550, 0.265, 1.550)"},settingsFromObject:function(a,b,c){var d=this;c&&(d=d.fork());for(var e in a){var f;c=a[e];if(a.hasOwnProperty(e)&&"undefined"!==typeof c){switch(e){case "animation":e="name";break;case "el":e="target";break;case "onBefore":e=
"before";break;case "onComplete":e="then"}(f=d[e])&&"function"===typeof f?f.call(d,c):console&&console.warn&&console.warn("Walt : could not convert old setting "+e)}}return b?d.animate():d}};return d}(d.Walt||{});d.Walt.animate=function(d){return(new Walt).settingsFromObject(d,!0)};d.mondo=d.mondo||{};d.mondo.Walt=d.Walt})(window,document,jQuery,async);