Skip to content

armgit / anime

Public Imported from GitHub
0

JavaScript animation engine

progress value fix

Julian Garnier454355b01548
diff --git a/anime.js b/anime.js
index 088b38e0..c0917b59 100644
--- a/anime.js
+++ b/anime.js
@@ -467,7 +467,7 @@
var setAnimationProgress = function(anim, time) {
var transform, str = 'transform', transforms = {};
anim.time = time;
- anim.progress = (time / anim.duration) * 100;
+ anim.progress = (Math.min(Math.max(time, 0), anim.duration) / anim.duration) * 100;
for (var t = 0; t < anim.tweens.length; t++) {
var tween = anim.tweens[t];
tween.currentValue = getTweenProgress(tween, time);
@@ -489,9 +489,10 @@
}
}
if (transforms) {
- if (!transform) transform = (getCSSValue(document.body, str) ? '' : '-webkit-') + str;
for (var t in transforms) {
- anim.animatables[t].target.style[transform] = transforms[t].join(' ');
+ var target = anim.animatables[t].target;
+ if (!transform) transform = (getCSSValue(target, str) ? '' : '-webkit-') + str;
+ target.style[transform] = transforms[t].join(' ');
}
}
if (anim.settings.update) anim.settings.update(anim);
@@ -521,13 +522,15 @@
var engine = (function() {
var play = function() { raf = requestAnimationFrame(step); };
var step = function(t) {
- for (var i = 0; i < animations.length; i++) animations[i].tick(t);
- play();
- }
- return {
- play: play,
- pause: function() { cancelAnimationFrame(raf); raf = 0; }
+ if (animations.length) {
+ for (var i = 0; i < animations.length; i++) animations[i].tick(t);
+ raf = requestAnimationFrame(step);
+ } else {
+ cancelAnimationFrame(step);
+ raf = 0;
+ }
}
+ return play;
})();
var animation = function(params) {
@@ -569,7 +572,6 @@
removeWillChange(anim);
var i = animations.indexOf(anim);
if (i > -1) animations.splice(i, 1);
- if (!animations.length) engine.pause();
}
anim.play = function(params) {
@@ -581,7 +583,7 @@
if (s.direction === 'alternate' && !s.loop) s.loop = 1;
setWillChange(anim);
animations.push(anim);
- if (!raf) engine.play();
+ if (!raf) engine();
}
anim.restart = function() {
diff --git a/anime.min.js b/anime.min.js
index a00d2b42..060c6f10 100644
--- a/anime.min.js
+++ b/anime.min.js
@@ -1 +1,19 @@
-!function(t,n){"function"==typeof define&&define.amd?define([],n):"object"==typeof module&&module.exports?module.exports=n():t.anime=n()}(this,function(){var t={duration:1e3,delay:0,loop:!1,autoplay:!0,direction:"normal",easing:"easeOutElastic",elasticity:400,round:!1,begin:void 0,update:void 0,complete:void 0},n=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY"],r=function(){return{array:function(t){return Array.isArray(t)},object:function(t){return Object.prototype.toString.call(t).indexOf("Object")>-1},svg:function(t){return t instanceof SVGElement},dom:function(t){return t.nodeType||r.svg(t)},number:function(t){return!isNaN(parseInt(t))},string:function(t){return"string"==typeof t},func:function(t){return"function"==typeof t},undef:function(t){return"undefined"==typeof t},"null":function(t){return"null"==typeof t},hex:function(t){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)},rgb:function(t){return/^rgb/.test(t)},rgba:function(t){return/^rgba/.test(t)},hsl:function(t){return/^hsl/.test(t)},color:function(t){return r.hex(t)||r.rgb(t)||r.rgba(t)||r.hsl(t)}}}(),e=window.performance||{offset:Date.now(),now:function(){return Date.now()-this.offset}},a=function(){var t={},n=["Quad","Cubic","Quart","Quint","Expo"],r={Sine:function(t){return 1-Math.cos(t*Math.PI/2)},Circ:function(t){return 1-Math.sqrt(1-t*t)},Elastic:function(t,n){if(0===t||1===t)return t;var r=1-Math.min(n,998)/1e3,e=t/1,a=e-1,o=r/(2*Math.PI)*Math.asin(1);return-(Math.pow(2,10*a)*Math.sin((a-o)*(2*Math.PI)/r))},Back:function(t){return t*t*(3*t-2)},Bounce:function(t){for(var n,r=4;t<((n=Math.pow(2,--r))-1)/11;);return 1/Math.pow(4,3-r)-7.5625*Math.pow((3*n-2)/22-t,2)}};return n.forEach(function(t,n){r[t]=function(t){return Math.pow(t,n+2)}}),Object.keys(r).forEach(function(n){var e=r[n];t["easeIn"+n]=e,t["easeOut"+n]=function(t,n){return 1-e(1-t,n)},t["easeInOut"+n]=function(t,n){return.5>t?e(2*t,n)/2:1-e(-2*t+2,n)/2}}),t.linear=function(t){return t},t}(),o=function(t){return r.string(t)?t:t+""},u=function(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},i=function(t){if(r.color(t))return!1;try{var n=document.querySelectorAll(t);return n}catch(e){return!1}},s=function(t,n){return Math.floor(Math.random()*(n-t+1))+t},c=function(t){return t.reduce(function(t,n){return t.concat(r.array(n)?c(n):n)},[])},f=function(t){return r.array(t)?t:(r.string(t)&&(t=i(t)||t),t instanceof NodeList||t instanceof HTMLCollection?[].slice.call(t):[t])},l=function(t,n){return t.some(function(t){return t===n})},d=function(t,n){var r={};return t.forEach(function(t){var e=JSON.stringify(n.map(function(n){return t[n]}));r[e]=r[e]||[],r[e].push(t)}),Object.keys(r).map(function(t){return r[t]})},p=function(t){return t.filter(function(t,n,r){return r.indexOf(t)===n})},m=function(t){var n={};for(var r in t)n[r]=t[r];return n},g=function(t,n){for(var e in n)t[e]=r.undef(t[e])?n[e]:t[e];return t},h=function(t){var n=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,t=t.replace(n,function(t,n,r,e){return n+n+r+r+e+e}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t),e=parseInt(r[1],16),a=parseInt(r[2],16),o=parseInt(r[3],16);return"rgb("+e+","+a+","+o+")"},v=function(t){var n,r,e,t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),a=parseInt(t[1])/360,o=parseInt(t[2])/100,u=parseInt(t[3])/100,i=function(t,n,r){return 0>r&&(r+=1),r>1&&(r-=1),1/6>r?t+6*(n-t)*r:.5>r?n:2/3>r?t+(n-t)*(2/3-r)*6:t};if(0==o)n=r=e=u;else{var s=.5>u?u*(1+o):u+o-u*o,c=2*u-s;n=i(c,s,a+1/3),r=i(c,s,a),e=i(c,s,a-1/3)}return"rgb("+255*n+","+255*r+","+255*e+")"},y=function(t){return r.rgb(t)||r.rgba(t)?t:r.hex(t)?h(t):r.hsl(t)?v(t):void 0},b=function(t){return/([\+\-]?[0-9|auto\.]+)(%|px|pt|em|rem|in|cm|mm|ex|pc|vw|vh|deg)?/.exec(t)[2]},w=function(t,n,r){return b(n)?n:t.indexOf("translate")>-1?b(r)?n+b(r):n+"px":t.indexOf("rotate")>-1||t.indexOf("skew")>-1?n+"deg":n},x=function(t,e){return r.dom(t)&&l(n,e)?"transform":r.dom(t)&&"transform"!==e&&M(t,e)?"css":r.dom(t)&&(t.getAttribute(e)||r.svg(t)&&t[e])?"attribute":r["null"](t[e])||r.undef(t[e])?void 0:"object"},M=function(t,n){return n in t.style?getComputedStyle(t).getPropertyValue(u(n))||"0":void 0},O=function(t,n){var r=n.indexOf("scale")>-1?1:0,e=t.style.transform;if(!e)return r;for(var a=/(\w+)\((.+?)\)/g,o=[],u=[],i=[];o=a.exec(e);)u.push(o[1]),i.push(o[2]);var s=i.filter(function(t,r){return u[r]===n});return s.length?s[0]:r},k=function(t,n){switch(x(t,n)){case"transform":return O(t,n);case"css":return M(t,n);case"attribute":return t.getAttribute(n)}return t[n]||0},E=function(t,n,e){if(r.color(n))return y(n);if(b(n))return n;var a=b(b(t.to)?t.to:t.from);return!a&&e&&(a=b(e)),a?n+a:n},I=function(t){var n=/-?\d*\.?\d+/g;return{original:t,numbers:o(t).match(n)?o(t).match(n).map(Number):[0],strings:o(t).split(n)}},A=function(t,n,r){return n.reduce(function(n,e,a){var e=e?e:r[a-1];return n+t[a-1]+e})},j=function(t){var t=t?c(r.array(t)?t.map(f):f(t)):[];return t.map(function(t,n){return{target:t,id:n}})},P=function(n,e){var a=[];for(var o in n)if(!t.hasOwnProperty(o)&&"targets"!==o){var u=r.object(n[o])?m(n[o]):{value:n[o]};u.name=o,a.push(g(u,e))}return a},C=function(t,n,e,a){var o=f(r.func(e)?e(t,a):e);return{from:o.length>1?o[0]:k(t,n),to:o.length>1?o[1]:o[0]}},S=function(t,n,r,e){var a={};if("transform"===r)a.from=t+"("+w(t,n.from,n.to)+")",a.to=t+"("+w(t,n.to)+")";else{var o="css"===r?M(e,t):void 0;a.from=E(n,n.from,o),a.to=E(n,n.to,o)}return{from:I(a.from),to:I(a.to)}},$=function(t,n){var e=[];return t.forEach(function(a,o){var u=a.target;return n.forEach(function(n){var i=x(u,n.name);if(i){var s=C(u,n.name,n.value,o),c=m(n);c.animatables=a,c.type=i,c.from=S(n.name,s,c.type,u).from,c.to=S(n.name,s,c.type,u).to,c.round=r.color(s.from)||c.round?1:0,c.delay=(r.func(c.delay)?c.delay(u,o,t.length):c.delay)/H.speed,c.duration=(r.func(c.duration)?c.duration(u,o,t.length):c.duration)/H.speed,e.push(c)}})}),e},L=function(t,n){var r=$(t,n),e=d(r,["name","from","to","delay","duration"]);return e.map(function(t){var n=m(t[0]);return n.animatables=t.map(function(t){return t.animatables}),n.totalDuration=n.delay+n.duration,n})},N=function(t,n){t.tweens.forEach(function(r){var e=r.to,a=r.from,o=t.duration-(r.delay+r.duration);r.from=e,r.to=a,n&&(r.delay=o)}),t.reversed=t.reversed?!1:!0},V=function(t){var n=[],r=[];return t.tweens.forEach(function(t){("css"===t.type||"transform"===t.type)&&(n.push("css"===t.type?u(t.name):"transform"),t.animatables.forEach(function(t){r.push(t.target)}))}),{properties:p(n).join(", "),elements:p(r)}},X=function(t){var n=V(t);n.elements.forEach(function(t){t.style.willChange=n.properties})},Y=function(t){var n=V(t);n.elements.forEach(function(t){t.style.removeProperty("will-change")})},D=function(t){var n=r.string(t)?i(t)[0]:t;return{path:n,value:n.getTotalLength()}},F=function(t,n){var r=t.path,e=t.value*n,a=function(a){var o=a||0,u=n>1?t.value+o:e+o;return r.getPointAtLength(u)},o=a(),u=a(-1),i=a(1);switch(t.name){case"translateX":return o.x;case"translateY":return o.y;case"rotate":return 180*Math.atan2(i.y-u.y,i.x-u.x)/Math.PI}},Z=function(t,n){var r=Math.min(Math.max(n-t.delay,0),t.duration),e=r/t.duration,o=t.to.numbers.map(function(n,r){var o=t.from.numbers[r],u=a[t.easing](e,t.elasticity),i=t.path?F(t,u):o+u*(n-o);return i=t.round?Math.round(i*t.round)/t.round:i});return A(o,t.to.strings,t.from.strings)},q=(M(document.body,"transform")?"":"-webkit-")+"transform",Q=function(t,n){var r={};t.time=Math.min(n,t.duration),t.progress=t.time/t.duration*100;for(var e=0;e<t.tweens.length;e++){var a=t.tweens[e];a.currentValue=Z(a,n);for(var o=a.currentValue,u=0;u<a.animatables.length;u++){var i=a.animatables[u],s=i.id;switch(a.type){case"css":i.target.style[a.name]=o;break;case"attribute":i.target.setAttribute(a.name,o);break;case"object":i.target[a.name]=o;break;case"transform":r[s]||(r[s]=[]),r[s].push(o)}}}if(r)for(var e in r)t.animatables[e].target.style[q]=r[e].join(" ");t.settings.update&&t.settings.update(t)},T=function(n){var r={};return r.animatables=j(n.targets),r.settings=g(n,t),r.properties=P(n,r.settings),r.tweens=L(r.animatables,r.properties),r.duration=r.tweens.length?Math.max.apply(Math,r.tweens.map(function(t){return t.totalDuration})):n.duration/H.speed,r.time=0,r.progress=0,r.running=!1,r.ended=!1,r},B=[],z=0,G=function(){var t=function(){z=requestAnimationFrame(r)},n=function(){cancelAnimationFrame(z),z=0},r=function(n){for(var r=0;r<B.length;r++)B[r].tick(n);t()};return{play:t,pause:n}}(),H=function(t){var n=T(t),a={};return n.tick=function(t){if(n.running){n.ended=!1,a.current=a.last+t-a.start,Q(n,a.current);var e=n.settings;e.begin&&a.current>=e.delay&&(e.begin(n),e.begin=void 0),a.current>=n.duration&&(e.loop?(a.start=t,"alternate"===e.direction&&N(n,!0),r.number(e.loop)&&e.loop--):(n.ended=!0,n.pause(),e.complete&&e.complete(n)),a.last=0)}},n.seek=function(t){var r=t/100*n.duration;Q(n,r)},n.pause=function(){n.running=!1,Y(n);var t=B.indexOf(n);t>-1&&B.splice(t,1),B.length||G.pause()},n.play=function(t){t&&(n=g(T(g(t,n.settings)),n)),n.pause(),n.running=!0,a.start=e.now(),a.last=n.ended?0:n.time;var r=n.settings;"reverse"===r.direction&&N(n),"alternate"!==r.direction||r.loop||(r.loop=1),X(n),B.push(n),z||G.play()},n.restart=function(){n.reversed&&N(n),n.pause(),n.seek(0),n.play()},n.settings.autoplay&&n.play(),n},J=function(t){for(var n=c(r.array(t)?t.map(f):f(t)),e=B.length-1;e>=0;e--)for(var a=B[e],o=a.tweens,u=o.length-1;u>=0;u--)for(var i=o[u].animatables,s=i.length-1;s>=0;s--)l(n,i[s].target)&&(i.splice(s,1),i.length||o.splice(u,1),o.length||a.pause())};return H.speed=1,H.list=B,H.remove=J,H.easings=a,H.getValue=k,H.path=D,H.random=s,H});
+(function(t,q){"function"===typeof define&&define.amd?define([],q):"object"===typeof module&&module.exports?module.exports=q():t.anime=q()})(this,function(){var t={duration:1E3,delay:0,loop:!1,autoplay:!0,direction:"normal",easing:"easeOutElastic",elasticity:400,round:!1,begin:void 0,update:void 0,complete:void 0},q="translateX translateY translateZ rotate rotateX rotateY rotateZ scale scaleX scaleY scaleZ skewX skewY".split(" "),f=function(){return{array:function(a){return Array.isArray(a)},object:function(a){return-1<
+Object.prototype.toString.call(a).indexOf("Object")},svg:function(a){return a instanceof SVGElement},dom:function(a){return a.nodeType||f.svg(a)},number:function(a){return!isNaN(parseInt(a))},string:function(a){return"string"===typeof a},func:function(a){return"function"===typeof a},undef:function(a){return"undefined"===typeof a},"null":function(a){return"null"===typeof a},hex:function(a){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(a)},rgb:function(a){return/^rgb/.test(a)},rgba:function(a){return/^rgba/.test(a)},
+hsl:function(a){return/^hsl/.test(a)},color:function(a){return f.hex(a)||f.rgb(a)||f.rgba(a)||f.hsl(a)}}}(),B=function(){var a={},b={Sine:function(a){return 1-Math.cos(a*Math.PI/2)},Circ:function(a){return 1-Math.sqrt(1-a*a)},Elastic:function(a,b){if(0===a||1===a)return a;var d=1-Math.min(b,998)/1E3,g=a/1-1;return-(Math.pow(2,10*g)*Math.sin(2*(g-d/(2*Math.PI)*Math.asin(1))*Math.PI/d))},Back:function(a){return a*a*(3*a-2)},Bounce:function(a){for(var b,d=4;a<((b=Math.pow(2,--d))-1)/11;);return 1/Math.pow(4,
+3-d)-7.5625*Math.pow((3*b-2)/22-a,2)}};["Quad","Cubic","Quart","Quint","Expo"].forEach(function(a,e){b[a]=function(a){return Math.pow(a,e+2)}});Object.keys(b).forEach(function(c){var e=b[c];a["easeIn"+c]=e;a["easeOut"+c]=function(a,b){return 1-e(1-a,b)};a["easeInOut"+c]=function(a,b){return.5>a?e(2*a,b)/2:1-e(-2*a+2,b)/2}});a.linear=function(a){return a};return a}(),x=function(a){return f.string(a)?a:a+""},C=function(a){return a.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},D=function(a){if(f.color(a))return!1;
+try{return document.querySelectorAll(a)}catch(b){return!1}},y=function(a){return a.reduce(function(a,c){return a.concat(f.array(c)?y(c):c)},[])},r=function(a){if(f.array(a))return a;f.string(a)&&(a=D(a)||a);return a instanceof NodeList||a instanceof HTMLCollection?[].slice.call(a):[a]},E=function(a,b){return a.some(function(a){return a===b})},R=function(a,b){var c={};a.forEach(function(a){var d=JSON.stringify(b.map(function(b){return a[b]}));c[d]=c[d]||[];c[d].push(a)});return Object.keys(c).map(function(a){return c[a]})},
+F=function(a){return a.filter(function(a,c,e){return e.indexOf(a)===c})},z=function(a){var b={},c;for(c in a)b[c]=a[c];return b},u=function(a,b){for(var c in b)a[c]=f.undef(a[c])?b[c]:a[c];return a},S=function(a){a=a.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(a,b,c,n){return b+b+c+c+n+n});var b=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);a=parseInt(b[1],16);var c=parseInt(b[2],16),b=parseInt(b[3],16);return"rgb("+a+","+c+","+b+")"},T=function(a){a=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(a);
+var b=parseInt(a[1])/360,c=parseInt(a[2])/100,e=parseInt(a[3])/100;a=function(a,b,c){0>c&&(c+=1);1<c&&--c;return c<1/6?a+6*(b-a)*c:.5>c?b:c<2/3?a+(b-a)*(2/3-c)*6:a};if(0==c)c=e=b=e;else var d=.5>e?e*(1+c):e+c-e*c,g=2*e-d,c=a(g,d,b+1/3),e=a(g,d,b),b=a(g,d,b-1/3);return"rgb("+255*c+","+255*e+","+255*b+")"},p=function(a){return/([\+\-]?[0-9|auto\.]+)(%|px|pt|em|rem|in|cm|mm|ex|pc|vw|vh|deg)?/.exec(a)[2]},H=function(a,b,c){return p(b)?b:-1<a.indexOf("translate")?p(c)?b+p(c):b+"px":-1<a.indexOf("rotate")||
+-1<a.indexOf("skew")?b+"deg":b},I=function(a,b){if(f.dom(a)&&E(q,b))return"transform";if(f.dom(a)&&"transform"!==b&&v(a,b))return"css";if(f.dom(a)&&(a.getAttribute(b)||f.svg(a)&&a[b]))return"attribute";if(!f["null"](a[b])&&!f.undef(a[b]))return"object"},v=function(a,b){if(b in a.style)return getComputedStyle(a).getPropertyValue(C(b))||"0"},U=function(a,b){var c=-1<b.indexOf("scale")?1:0,e=a.style.transform;if(!e)return c;for(var d=/(\w+)\((.+?)\)/g,g=[],n=[],f=[];g=d.exec(e);)n.push(g[1]),f.push(g[2]);
+e=f.filter(function(a,c){return n[c]===b});return e.length?e[0]:c},J=function(a,b){switch(I(a,b)){case "transform":return U(a,b);case "css":return v(a,b);case "attribute":return a.getAttribute(b)}return a[b]||0},K=function(a,b,c){if(f.color(b))return b=f.rgb(b)||f.rgba(b)?b:f.hex(b)?S(b):f.hsl(b)?T(b):void 0,b;if(p(b))return b;a=p(a.to)?p(a.to):p(a.from);!a&&c&&(a=p(c));return a?b+a:b},L=function(a){var b=/-?\d*\.?\d+/g;return{original:a,numbers:x(a).match(b)?x(a).match(b).map(Number):[0],strings:x(a).split(b)}},
+V=function(a,b,c){return b.reduce(function(b,d,g){d=d?d:c[g-1];return b+a[g-1]+d})},W=function(a){a=a?y(f.array(a)?a.map(r):r(a)):[];return a.map(function(a,c){return{target:a,id:c}})},M=function(a,b,c,e){"transform"===c?(c=a+"("+H(a,b.from,b.to)+")",b=a+"("+H(a,b.to)+")"):(a="css"===c?v(e,a):void 0,c=K(b,b.from,a),b=K(b,b.to,a));return{from:L(c),to:L(b)}},X=function(a,b){var c=[];a.forEach(function(e,d){var g=e.target;return b.forEach(function(b){var G=I(g,b.name);if(G){var l;l=b.name;var h=b.value,
+h=r(f.func(h)?h(g,d):h);l={from:1<h.length?h[0]:J(g,l),to:1<h.length?h[1]:h[0]};h=z(b);h.animatables=e;h.type=G;h.from=M(b.name,l,h.type,g).from;h.to=M(b.name,l,h.type,g).to;h.round=f.color(l.from)||h.round?1:0;h.delay=(f.func(h.delay)?h.delay(g,d,a.length):h.delay)/k.speed;h.duration=(f.func(h.duration)?h.duration(g,d,a.length):h.duration)/k.speed;c.push(h)}})});return c},Y=function(a,b){var c=X(a,b);return R(c,["name","from","to","delay","duration"]).map(function(a){var b=z(a[0]);b.animatables=
+a.map(function(a){return a.animatables});b.totalDuration=b.delay+b.duration;return b})},A=function(a,b){a.tweens.forEach(function(c){var e=c.from,d=a.duration-(c.delay+c.duration);c.from=c.to;c.to=e;b&&(c.delay=d)});a.reversed=a.reversed?!1:!0},Z=function(a){if(a.length)return Math.max.apply(Math,a.map(function(a){return a.totalDuration}))},N=function(a){var b=[],c=[];a.tweens.forEach(function(a){if("css"===a.type||"transform"===a.type)b.push("css"===a.type?C(a.name):"transform"),a.animatables.forEach(function(a){c.push(a.target)})});
+return{properties:F(b).join(", "),elements:F(c)}},aa=function(a){var b=N(a);b.elements.forEach(function(a){a.style.willChange=b.properties})},ba=function(a){N(a).elements.forEach(function(a){a.style.removeProperty("will-change")})},ca=function(a,b){var c=a.path,e=a.value*b,d=function(d){d=d||0;return c.getPointAtLength(1<b?a.value+d:e+d)},g=d(),f=d(-1),d=d(1);switch(a.name){case "translateX":return g.x;case "translateY":return g.y;case "rotate":return 180*Math.atan2(d.y-f.y,d.x-f.x)/Math.PI}},da=
+function(a,b){var c=Math.min(Math.max(b-a.delay,0),a.duration)/a.duration,e=a.to.numbers.map(function(b,e){var f=a.from.numbers[e],k=B[a.easing](c,a.elasticity),f=a.path?ca(a,k):f+k*(b-f);return f=a.round?Math.round(f*a.round)/a.round:f});return V(e,a.to.strings,a.from.strings)},O=function(a,b){var c,e={};a.time=b;a.progress=b/a.duration*100;for(var d=0;d<a.tweens.length;d++){var f=a.tweens[d];f.currentValue=da(f,b);for(var n=f.currentValue,k=0;k<f.animatables.length;k++){var l=f.animatables[k],h=
+l.id,l=l.target,m=f.name;switch(f.type){case "css":l.style[m]=n;break;case "attribute":l.setAttribute(m,n);break;case "object":l[m]=n;break;case "transform":e[h]||(e[h]=[]),e[h].push(n)}}}if(e)for(d in c||(c=(v(document.body,"transform")?"":"-webkit-")+"transform"),e)a.animatables[d].target.style[c]=e[d].join(" ");a.settings.update&&a.settings.update(a)},P=function(a){var b={};b.animatables=W(a.targets);b.settings=u(a,t);var c=b.settings,e=[],d;for(d in a)if(!t.hasOwnProperty(d)&&"targets"!==d){var g=
+f.object(a[d])?z(a[d]):{value:a[d]};g.name=d;e.push(u(g,c))}b.properties=e;b.tweens=Y(b.animatables,b.properties);b.duration=Z(b.tweens)||a.duration;b.time=0;b.progress=0;b.running=!1;b.ended=!1;return b},m=[],w=0,Q=function(){var a=function(){w=requestAnimationFrame(b)},b=function(b){for(var e=0;e<m.length;e++)m[e].tick(b);a()};return{play:a,pause:function(){cancelAnimationFrame(w);w=0}}}(),k=function(a){var b=P(a),c={};b.tick=function(a){if(b.running){b.ended=!1;c.start||(c.start=a);c.current=c.last+
+a-c.start;O(b,c.current);var d=b.settings;d.begin&&c.current>=d.delay&&(d.begin(b),d.begin=void 0);c.current>=b.duration&&(d.loop?(c.start=a,"alternate"===d.direction&&A(b,!0),f.number(d.loop)&&d.loop--):(b.ended=!0,b.pause(),d.complete&&d.complete(b)),c.last=0)}};b.seek=function(a){O(b,a/100*b.duration)};b.pause=function(){b.running=!1;c.start=0;ba(b);var a=m.indexOf(b);-1<a&&m.splice(a,1);m.length||Q.pause()};b.play=function(a){a&&(b=u(P(u(a,b.settings)),b));b.running=!0;c.last=b.ended?0:b.time;
+a=b.settings;"reverse"===a.direction&&A(b);"alternate"!==a.direction||a.loop||(a.loop=1);aa(b);m.push(b);w||Q.play()};b.restart=function(){b.reversed&&A(b);b.pause();b.seek(0);b.play()};b.settings.autoplay&&b.play();return b};k.speed=1;k.list=m;k.remove=function(a){a=y(f.array(a)?a.map(r):r(a));for(var b=m.length-1;0<=b;b--)for(var c=m[b],e=c.tweens,d=e.length-1;0<=d;d--)for(var g=e[d].animatables,k=g.length-1;0<=k;k--)E(a,g[k].target)&&(g.splice(k,1),g.length||e.splice(d,1),e.length||c.pause())};
+k.easings=B;k.getValue=J;k.path=function(a){a=f.string(a)?D(a)[0]:a;return{path:a,value:a.getTotalLength()}};k.random=function(a,b){return Math.floor(Math.random()*(b-a+1))+a};return k});
diff --git a/examples/playback.html b/examples/playback.html
index 9ab3bf1f..09c78662 100644
--- a/examples/playback.html
+++ b/examples/playback.html
@@ -42,6 +42,7 @@
<button class="play">Play</button>
<button class="pause">Pause</button>
<button class="restart">Restart</button>
+ <input class="percents" type="text"></input>
</fieldset>
</section>
<script src="../anime.js"></script>
@@ -51,6 +52,7 @@
var pauseButton = document.querySelector('.pause');
var restartButton = document.querySelector('.restart');
var progress = document.querySelector('.progress');
+ var percents = document.querySelector('.percents');
var myAnimation = anime({
targets: 'div',
@@ -61,6 +63,7 @@
easing: 'easeOutQuad',
update: function(animation) {
progress.value = animation.progress;
+ percents.value = animation.progress + '%';
}
});