-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathjanis.min.js
7 lines (7 loc) · 3.23 KB
/
janis.min.js
1
2
3
4
5
6
7
var Janis=function(d){var a,c=[];if(d instanceof NodeList||d instanceof HTMLCollection)for(a=0;a<d.length;++a)c.push(d[a]);else if(typeof d==="string"){d=document.querySelectorAll(d);for(a=0;a<d.length;++a)c.push(d[a])}else if(d instanceof Array)c=d;else c.push(d);return new Janis.pt.I(c)};Janis.config={easing:"ease",duration:0,delay:0};
Janis.pt=Janis.prototype={C:{},r:[],c:0,p:0,b:"",u:"undefined",t:"transition",I:function(d){var a,c=["moz","o","webkit","ms"],e=Janis.config.pre,b=this,i=b.t;b.r=d;b.L=[];b.Q=[];if(typeof e===b.u){a=document.createElement("div");c.forEach(function(f){a.style[b.A(f)+"Transition"]="all 1s ease";if(a.style[b.A(f)+"TransitionProperty"])e=b.A(f)+"Transition"});e=e?e:i;Janis.config.pre=e}c.forEach(function(f){if(e.toLowerCase().indexOf(f.toLowerCase())===0)b.b="-"+f+"-"});b.p=e;b.r.forEach(function(f){f.style[e]=
"all 1s ease"});return b},R:function(d){return d instanceof Array},A:function(d){return d.charAt(0).toUpperCase()+d.substr(1).toLowerCase()},f:function(d){var a="",c=this;d.split("-").forEach(function(e,b){a+=b?c.A(e):e.toLowerCase()});return a},a:function(d,a){var c,e,b=this,i;a.index=++b.c;if(typeof a.duration===b.u)a.duration=Janis.config.duration;if(typeof a.delay===b.u)a.delay=Janis.config.delay;if(typeof a.easing===b.u)a.easing=Janis.config.easing;if(typeof a.callback===b.u)a.callback=function(){};
if(!b.R(a.callback))a.callback=[a.callback];b.C[a.index]=a.callback;c=b.r[d];c.style[b.p]=a.duration==0?"none":"all "+a.duration+"ms "+a.easing;i=function(){var f;for(f in a.css)if(a.css.hasOwnProperty(f)){e=a.css[f];f=b.f(f);c.style[f]=e}};a.delay?setTimeout(i,a.delay):i();setTimeout(function(){b.C[a.index].forEach(function(f){if(typeof f==="function")f(b,a);else b.R(f)&&f[0].apply(b,f[1])})},a.delay+a.duration+1);return b},animate:function(d,a){var c,e=-1,b=this;if(!b.R(d)){d=[d];for(c=1;c<b.r.length;++c)d.push(d[0])}if(b.h&&
!a){b.Q.push(["animate",[d,1]]);return b}b.r.forEach(function(i,f){var g,h,j={css:{}},k="";if(!d[f]&&e===-1)return b;if(d[f]){h=d[f];e=f}else h=d[e];for(g in h)if(h.hasOwnProperty(g))if(g==="duration"||g==="delay"||g==="easing"||g==="callback")j[g]=h[g];else if(g==="rotate"||g.indexOf("translate")===0||g.indexOf("skew")===0)k+=g+"("+h[g]+") ";else if(g==="transform")k+=h[g];else if(g==="transform-origin")j.css[b.b+g]=h[g];else j.css[g]=h[g];if(k.length)j.css[b.b+"transform"]=k;b.a(f,j)});return b},
m:function(d){var a=-1,c=-1,e=this;d.forEach(function(b){if(typeof b.duration===e.u)b.duration=Janis.config.duration;if(typeof b.delay===e.u)b.delay=Janis.config.delay;c=b.duration+b.delay;if(c>a)a=c});return a},h:0,Q:[],chain:function(){this.h=1;this.Q=[];return this},execute:function(){if(!this.Q.length)return this;return this.loop(1)},n:function(d){var a=this.Q.shift();if(!a)return d?[]:this;this[a[0]].apply(this,a[1]);return d?a:this},l:0,L:[],loop:function(d,a){var c=this,e;c.h=0;if(!a){if(!c.Q.length)return c;
if(typeof d===c.u)d=-1;c.l=d;c.L=c.Q.concat()}if(!c.Q.length&&c.L.length){c.Q=c.L.concat();c.l>-1&&--c.l}if(c.l===0||!c.Q.length)return c;if(!c.paused){e=c.n(1);if(e.length){e=c.m(e[1][0]);setTimeout(function(){c.loop(c.l,1)},e)}}return c},paused:0,pause:function(){this.paused=1;return this},play:function(){this.paused=0;this.loop(this.l,1);return this}};Janis.pt.I.prototype=Janis.pt;