anime.min.js 11 KB

1
  1. var $jscomp$this=this;(function(b,a){"function"===typeof define&&define.amd?define([],a):"object"===typeof module&&module.exports?module.exports=a():b.anime=a()})(this,function(){function am(g){if(!o.col(g)){try{return document.querySelectorAll(g)}catch(n){}}}function ah(g){return g.reduce(function(n,p){return n.concat(o.arr(p)?ah(p):p)},[])}function ao(g){if(o.arr(g)){return g}o.str(g)&&(g=am(g)||g);return g instanceof NodeList||g instanceof HTMLCollection?[].slice.call(g):[g]}function l(g,n){return g.some(function(p){return p===n})}function a(g){var n={},p;for(p in g){n[p]=g[p]}return n}function r(g,n){var q=a(g),p;for(p in g){q[p]=n.hasOwnProperty(p)?n[p]:g[p]}return q}function c(g,n){var q=a(g),p;for(p in n){q[p]=o.und(g[p])?n[p]:g[p]}return q}function aj(g){g=g.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(q,v,w,x){return v+v+w+w+x+x});var n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(g);g=parseInt(n[1],16);var p=parseInt(n[2],16),n=parseInt(n[3],16);return"rgb("+g+","+p+","+n+")"}function ak(g){function n(x,y,z){0>z&&(z+=1);1<z&&--z;return z<1/6?x+6*(y-x)*z:0.5>z?y:z<2/3?x+(y-x)*(2/3-z)*6:x}var q=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(g);g=parseInt(q[1])/360;var p=parseInt(q[2])/100,q=parseInt(q[3])/100;if(0==p){p=q=g=q}else{var v=0.5>q?q*(1+p):q+p-q*p,w=2*q-v,p=n(w,v,g+1/3),q=n(w,v,g);g=n(w,v,g-1/3)}return"rgb("+255*p+","+255*q+","+255*g+")"}function aq(g){if(g=/([\+\-]?[0-9#\.]+)(%|px|pt|em|rem|in|cm|mm|ex|pc|vw|vh|deg|rad|turn)?/.exec(g)){return g[2]}}function al(g){if(-1<g.indexOf("translate")){return"px"}if(-1<g.indexOf("rotate")||-1<g.indexOf("skew")){return"deg"}}function t(g,n){return o.fnc(g)?g(n.target,n.id,n.total):g}function e(g,n){if(n in g.style){return getComputedStyle(g).getPropertyValue(n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase())||"0"}}function P(g,n){if(o.dom(g)&&l(an,n)){return"transform"}if(o.dom(g)&&(g.getAttribute(n)||o.svg(g)&&g[n])){return"attribute"}if(o.dom(g)&&"transform"!==n&&e(g,n)){return"css"}if(null!=g[n]){return"object"}}function ap(g,n){var q=al(n),q=-1<n.indexOf("scale")?1:0+q;g=g.style.transform;if(!g){return q}for(var p=[],v=[],x=[],w=/(\w+)\((.+?)\)/g;p=w.exec(g);){v.push(p[1]),x.push(p[2])}g=x.filter(function(y,z){return v[z]===n});return g.length?g[0]:q}function R(g,n){switch(P(g,n)){case"transform":return ap(g,n);case"css":return e(g,n);case"attribute":return g.getAttribute(n)}return g[n]||0}function ab(g,n){var p=/^(\*=|\+=|-=)/.exec(g);if(!p){return g}n=parseFloat(n);g=parseFloat(g.replace(p[0],""));switch(p[0][0]){case"+":return n+g;case"-":return n-g;case"*":return n*g}}function h(g){return o.obj(g)&&g.hasOwnProperty("totalLength")}function ar(g,n){function q(x){x=void 0===x?0:x;return g.el.getPointAtLength(1<=n+x?n+x:0)}var p=q(),v=q(-1),w=q(1);switch(g.property){case"x":return p.x;case"y":return p.y;case"angle":return 180*Math.atan2(w.y-v.y,w.x-v.x)/Math.PI}}function ac(g,n){var q=/-?\d*\.?\d+/g;g=h(g)?g.totalLength:g;if(o.col(g)){n=o.rgb(g)?g:o.hex(g)?aj(g):o.hsl(g)?ak(g):void 0}else{var p=aq(g);g=p?g.substr(0,g.length-p.length):g;n=n?g+n:g}n+="";return{original:n,numbers:n.match(q)?n.match(q).map(Number):[0],strings:n.split(q)}}function au(g,n){return n.reduce(function(p,q,v){return p+g[v-1]+q})}function ad(g){return(g?ah(o.arr(g)?g.map(ao):ao(g)):[]).filter(function(n,q,p){return p.indexOf(n)===q})}function aw(g){var n=ad(g);return n.map(function(p,q){return{target:p,id:q,total:n.length}})}function b(g,n){var q=a(n);if(o.arr(g)){var p=g.length;2!==p||o.obj(g[0])?o.fnc(n.duration)||(q.duration=n.duration/p):g={value:g}}return ao(g).map(function(v,w){w=w?0:n.delay;v=o.obj(v)&&!h(v)?v:{value:v};o.und(v.delay)&&(v.delay=w);return v}).map(function(v){return c(v,q)})}function d(g,n){var q={},p;for(p in g){var v=t(g[p],n);o.arr(v)&&(v=v.map(function(w){return t(w,n)}),1===v.length&&(v=v[0]));q[p]=v}q.duration=parseFloat(q.duration);q.delay=parseFloat(q.delay);return q}function f(g){return o.arr(g)?at.apply(this,g):af[g]}function i(g,n){var p;return g.tweens.map(function(q){q=d(q,n);var v=q.value,x=R(n.target,g.name),w=p?p.to.original:x,w=o.arr(v)?v[0]:w,y=ab(o.arr(v)?v[1]:v,w),x=aq(y)||aq(w)||aq(x);q.isPath=h(v);q.from=ac(w,x);q.to=ac(y,x);q.start=p?p.end:g.offset;q.end=q.start+q.delay+q.duration;q.easing=f(q.easing);q.elasticity=(1000-Math.min(Math.max(q.elasticity,1),999))/1000;o.col(q.from.original)&&(q.round=1);return p=q})}function k(g,n){return ah(g.map(function(p){return n.map(function(q){var v=P(p.target,q.name);if(v){var w=i(q,p);q={type:v,property:q.name,animatable:p,tweens:w,duration:w[w.length-1].end,delay:w[0].delay}}else{q=void 0}return q})})).filter(function(p){return !o.und(p)})}function ag(g,n,q){var p="delay"===g?Math.min:Math.max;return n.length?p.apply(Math,n.map(function(v){return v[g]})):q[g]}function m(n){var p=r(s,n),v=r(u,n),q=aw(n.targets),w=[],x=c(p,v),y;for(y in n){x.hasOwnProperty(y)||"targets"===y||w.push({name:y,offset:x.offset,tweens:b(n[y],v)})}n=k(q,w);return c(p,{children:[],animatables:q,animations:n,duration:ag("duration",n,v),delay:ag("delay",n,v)})}function ae(n){function p(){return window.Promise&&new Promise(function(g){return C=g})}function v(g){return x.reversed?x.duration-g:g}function q(F){for(var G=0,H={},I=x.animations,J={};G<I.length;){var K=I[G],L=K.animatable,N=K.tweens;J.tween=N.filter(function(g){return F<g.end})[0]||N[N.length-1];J.isPath$1=J.tween.isPath;J.round=J.tween.round;J.eased=J.tween.easing(Math.min(Math.max(F-J.tween.start-J.tween.delay,0),J.tween.duration)/J.tween.duration,J.tween.elasticity);N=au(J.tween.to.numbers.map(function(g){return function(O,S){S=g.isPath$1?0:g.tween.from.numbers[S];O=S+g.eased*(O-S);g.isPath$1&&(O=ar(g.tween.value,O));g.round&&(O=Math.round(O*g.round)/g.round);return O}}(J)),J.tween.to.strings);Q[K.type](L.target,K.property,N,H,L.id);K.currentValue=N;G++;J={isPath$1:J.isPath$1,tween:J.tween,eased:J.eased,round:J.round}}if(H){for(var M in H){j||(j=e(document.body,"transform")?"transform":"-webkit-transform"),x.animatables[M].target.style[j]=H[M].join(" ")}}x.currentTime=F;x.progress=F/x.duration*100}function w(g){if(x[g]){x[g](x)}}function y(){x.remaining&&!0!==x.remaining&&x.remaining--}function z(g){var F=x.duration,G=x.offset,H=x.delay,J=x.currentTime,K=x.reversed,L=v(g),L=Math.min(Math.max(L,0),F);if(x.children){var I=x.children;if(L>=x.currentTime){for(var M=0;M<I.length;M++){I[M].seek(L)}}else{for(M=I.length;M--;){I[M].seek(L)}}}L>G&&L<F?(q(L),!x.began&&L>=H&&(x.began=!0,w("begin")),w("run")):(L<=G&&0!==J&&(q(0),K&&y()),L>=F&&J!==F&&(q(F),K||y()));g>=F&&(x.remaining?(E=B,"alternate"===x.direction&&(x.reversed=!x.reversed)):(x.pause(),"Promise" in window&&(C(),D=p()),x.completed||(x.completed=!0,w("complete"))),A=0);w("update")}n=void 0===n?{}:n;var B,E,A=0,C=null,D=p(),x=m(n);x.reset=function(){var g=x.direction,F=x.loop;x.currentTime=0;x.progress=0;x.paused=!0;x.began=!1;x.completed=!1;x.reversed="reverse"===g;x.remaining="alternate"===g&&1===F?2:F;for(g=x.children.length;g--;){F=x.children[g],F.seek(F.offset),F.reset()}};x.tick=function(g){B=g;E||(E=B);z((A+B-E)*ae.speed)};x.seek=function(g){z(v(g))};x.pause=function(){var g=ai.indexOf(x);-1<g&&ai.splice(g,1);x.paused=!0};x.play=function(){x.paused&&(x.paused=!1,E=0,A=v(x.currentTime),ai.push(x),av||aa())};x.reverse=function(){x.reversed=!x.reversed;E=0;A=v(x.currentTime)};x.restart=function(){x.pause();x.reset();x.play()};x.finished=D;x.reset();x.autoplay&&x.play();return x}var s={update:void 0,begin:void 0,run:void 0,complete:void 0,loop:1,direction:"normal",autoplay:!0,offset:0},u={duration:1000,delay:0,easing:"easeOutElastic",elasticity:500,round:0},an="translateX translateY translateZ rotate rotateX rotateY rotateZ scale scaleX scaleY scaleZ skewX skewY".split(" "),j,o={arr:function(g){return Array.isArray(g)},obj:function(g){return -1<Object.prototype.toString.call(g).indexOf("Object")},svg:function(g){return g instanceof SVGElement},dom:function(g){return g.nodeType||o.svg(g)},str:function(g){return"string"===typeof g},fnc:function(g){return"function"===typeof g},und:function(g){return"undefined"===typeof g},hex:function(g){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(g)},rgb:function(g){return/^rgb/.test(g)},hsl:function(g){return/^hsl/.test(g)},col:function(g){return o.hex(g)||o.rgb(g)||o.hsl(g)}},at=function(){function g(n,q,p){return(((1-3*p+3*q)*n+(3*p-6*q))*n+3*q)*n}return function(n,q,p,v){if(0<=n&&1>=n&&0<=p&&1>=p){var w=new Float32Array(11);if(n!==q||p!==v){for(var x=0;11>x;++x){w[x]=g(0.1*x,n,p)}}return function(z){if(n===q&&p===v){return z}if(0===z){return 0}if(1===z){return 1}for(var C=0,A=1;10!==A&&w[A]<=z;++A){C+=0.1}--A;var A=C+(z-w[A])/(w[A+1]-w[A])*0.1,B=3*(1-3*p+3*n)*A*A+2*(3*p-6*n)*A+3*n;if(0.001<=B){for(C=0;4>C;++C){B=3*(1-3*p+3*n)*A*A+2*(3*p-6*n)*A+3*n;if(0===B){break}var D=g(A,n,p)-z,A=A-D/B}z=A}else{if(0===B){z=A}else{var A=C,C=C+0.1,y=0;do{D=A+(C-A)/2,B=g(D,n,p)-z,0<B?C=D:A=D}while(1e-07<Math.abs(B)&&10>++y);z=D}}return g(z,q,v)}}}}(),af=function(){function g(x,y){return 0===x||1===x?x:-Math.pow(2,10*(x-1))*Math.sin(2*(x-1-y/(2*Math.PI)*Math.asin(1))*Math.PI/y)}var n="Quad Cubic Quart Quint Sine Expo Circ Back Elastic".split(" "),q={In:[[0.55,0.08500000000000001,0.6800000000000001,0.53],[0.55,0.055,0.675,0.19],[0.895,0.03,0.6850000000000001,0.22],[0.755,0.05,0.855,0.06],[0.47,0,0.745,0.715],[0.95,0.05,0.795,0.035],[0.6,0.04,0.98,0.335],[0.6,-0.28,0.735,0.045],g],Out:[[0.25,0.46,0.45,0.94],[0.215,0.61,0.355,1],[0.165,0.84,0.44,1],[0.23,1,0.32,1],[0.39,0.575,0.565,1],[0.19,1,0.22,1],[0.075,0.82,0.165,1],[0.175,0.885,0.32,1.275],function(x,y){return 1-g(1-x,y)}],InOut:[[0.455,0.03,0.515,0.955],[0.645,0.045,0.355,1],[0.77,0,0.175,1],[0.86,0,0.07000000000000001,1],[0.445,0.05,0.55,0.95],[1,0,0,1],[0.785,0.135,0.15,0.86],[0.6800000000000001,-0.55,0.265,1.55],function(x,y){return 0.5>x?g(2*x,y)/2:1-g(-2*x+2,y)/2}]},p={linear:at(0.25,0.25,0.75,0.75)},v={},w;for(w in q){v.type=w,q[v.type].forEach(function(x){return function(y,z){p["ease"+x.type+n[z]]=o.fnc(y)?y:at.apply($jscomp$this,y)}}(v)),v={type:v.type}}return p}(),Q={css:function(g,n,p){return g.style[n]=p},attribute:function(g,n,p){return g.setAttribute(n,p)},object:function(g,n,p){return g[n]=p},transform:function(g,n,q,p,v){p[v]||(p[v]=[]);p[v].push(n+"("+q+")")}},ai=[],av=0,aa=function(){function g(){av=requestAnimationFrame(n)}function n(p){var q=ai.length;if(q){for(var v=0;v<q;){ai[v]&&ai[v].tick(p),v++}g()}else{cancelAnimationFrame(av),av=0}}return g}();ae.version="2.0.2";ae.speed=1;ae.running=ai;ae.remove=function(g){g=ad(g);for(var n=ai.length;n--;){for(var q=ai[n],p=q.animations,v=p.length;v--;){l(g,p[v].animatable.target)&&(p.splice(v,1),p.length||q.pause())}}};ae.getValue=R;ae.path=function(g,n){var q=o.str(g)?am(g)[0]:g,p=n||100;return function(v){return{el:q,property:v,totalLength:q.getTotalLength()*(p/100)}}};ae.setDashoffset=function(g){var n=g.getTotalLength();g.setAttribute("stroke-dasharray",n);return n};ae.bezier=at;ae.easings=af;ae.timeline=function(g){var n=ae(g);n.pause();n.duration=0;n.add=function(p){n.children.forEach(function(q){q.began=!0;q.completed=!0});ao(p).forEach(function(q){var v=n.duration,w=q.offset;q.autoplay=!1;q.offset=o.und(w)?v:ab(w,v);n.seek(q.offset);q=ae(q);q.duration>v&&(n.duration=q.duration);q.began=!0;n.children.push(q)});n.reset();n.seek(0);n.autoplay&&n.restart();return n};return n};ae.random=function(g,n){return Math.floor(Math.random()*(n-g+1))+g};return ae});