Skip to content

armgit / anime

Public Imported from GitHub
0

JavaScript animation engine

Clean up easing code

Julian Garniera3c92f3b689d
diff --git a/anime.js b/anime.js
index ca690e38..e1cf5684 100644
--- a/anime.js
+++ b/anime.js
@@ -88,7 +88,8 @@
} else {
progress = (a + b * progress) * Math.exp(-progress * w0);
}
- return t === 0 || t === 1 ? t : 1 - progress;
+ if (t === 0 || t === 1) return t;
+ return 1 - progress;
}
function getDuration() {
@@ -199,7 +200,8 @@
return x => {
if (mX1 === mY1 && mX2 === mY2) return x;
- return x === 0 || x === 1 ? x : calcBezier(getTForX(x), mY1, mY2);
+ if (x === 0 || x === 1) return x;
+ return calcBezier(getTForX(x), mY1, mY2);
}
}
@@ -248,11 +250,13 @@
]
}
- let eases = { linear: t => t };
+ let eases = {
+ linear: [0.250, 0.250, 0.750, 0.750]
+ }
for (let type in equations) {
equations[type].forEach((ease, i) => {
- eases[stringToHyphens(type+names[i])] = ease;
+ eases['ease'+type+names[i]] = ease;
});
}
@@ -617,7 +621,7 @@
if (!instanceSettings.hasOwnProperty(p) && !tweenSettings.hasOwnProperty(p) && p !== 'targets') {
properties.push({
name: p,
- offset: instanceSettings['timeOffset'],
+ timeOffset: instanceSettings['timeOffset'],
tweens: normalizePropertyTweens(params[p], tweenSettings)
});
}
@@ -654,7 +658,7 @@
const unit = getUnit(to) || getUnit(from) || getUnit(originalValue);
tween.from = decomposeValue(from, unit);
tween.to = decomposeValue(to, unit);
- tween.start = previousTween ? previousTween.end : prop.offset;
+ tween.start = previousTween ? previousTween.end : prop.timeOffset;
tween.end = tween.start + tween.delay + tween.duration + tween.endDelay;
tween.easing = parseEasings(tween);
tween.isPath = is.pth(tweenValue);
diff --git a/anime.min.js b/anime.min.js
index 753a8b0b..99334725 100644
--- a/anime.min.js
+++ b/anime.min.js
@@ -1,44 +1,27 @@
-/*
- 2017 Julian Garnier
- Released under the MIT license
-*/
-var $jscomp$this=this,$jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,h,c){a!=Array.prototype&&a!=Object.prototype&&(a[h]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);
-$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.Symbol=function(){var a=0;return function(h){return $jscomp.SYMBOL_PREFIX+(h||"")+a++}}();
-$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(a){var h=0;return $jscomp.iteratorPrototype(function(){return h<a.length?{done:!1,value:a[h++]}:{done:!0}})};
-$jscomp.iteratorPrototype=function(a){$jscomp.initSymbolIterator();a={next:a};a[$jscomp.global.Symbol.iterator]=function(){return this};return a};$jscomp.makeIterator=function(a){$jscomp.initSymbolIterator();$jscomp.initSymbol();$jscomp.initSymbolIterator();var h=a[Symbol.iterator];return h?h.call(a):$jscomp.arrayIterator(a)};$jscomp.owns=function(a,h){return Object.prototype.hasOwnProperty.call(a,h)};
-$jscomp.polyfill=function(a,h,c,g){if(h){c=$jscomp.global;a=a.split(".");for(g=0;g<a.length-1;g++){var p=a[g];p in c||(c[p]={});c=c[p]}a=a[a.length-1];g=c[a];h=h(g);h!=g&&null!=h&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:h})}};
-$jscomp.polyfill("WeakMap",function(a){function h(a){$jscomp.owns(a,g)||$jscomp.defineProperty(a,g,{value:{}})}function c(a){var f=Object[a];f&&(Object[a]=function(a){h(a);return f(a)})}if(function(){if(!a||!Object.seal)return!1;try{var h=Object.seal({}),f=Object.seal({}),c=new a([[h,2],[f,3]]);if(2!=c.get(h)||3!=c.get(f))return!1;c.delete(h);c.set(f,4);return!c.has(h)&&4==c.get(f)}catch(I){return!1}}())return a;var g="$jscomp_hidden_"+Math.random().toString().substring(2);c("freeze");c("preventExtensions");
-c("seal");var p=0,t=function(a){this.id_=(p+=Math.random()+1).toString();if(a){$jscomp.initSymbol();$jscomp.initSymbolIterator();a=$jscomp.makeIterator(a);for(var f;!(f=a.next()).done;)f=f.value,this.set(f[0],f[1])}};t.prototype.set=function(a,f){h(a);if(!$jscomp.owns(a,g))throw Error("WeakMap key fail: "+a);a[g][this.id_]=f;return this};t.prototype.get=function(a){return $jscomp.owns(a,g)?a[g][this.id_]:void 0};t.prototype.has=function(a){return $jscomp.owns(a,g)&&$jscomp.owns(a[g],this.id_)};t.prototype.delete=
-function(a){return $jscomp.owns(a,g)&&$jscomp.owns(a[g],this.id_)?delete a[g][this.id_]:!1};return t},"es6","es3");$jscomp.MapEntry=function(){};
-$jscomp.polyfill("Map",function(a){if(!$jscomp.ASSUME_NO_NATIVE_MAP&&function(){if(!a||!a.prototype.entries||"function"!=typeof Object.seal)return!1;try{var f=Object.seal({x:4}),c=new a($jscomp.makeIterator([[f,"s"]]));if("s"!=c.get(f)||1!=c.size||c.get({x:4})||c.set({x:4},"t")!=c||2!=c.size)return!1;var h=c.entries(),g=h.next();if(g.done||g.value[0]!=f||"s"!=g.value[1])return!1;g=h.next();return g.done||4!=g.value[0].x||"t"!=g.value[1]||!h.next().done?!1:!0}catch(D){return!1}}())return a;$jscomp.initSymbol();
-$jscomp.initSymbolIterator();var h=new WeakMap,c=function(a){this.data_={};this.head_=t();this.size=0;if(a){a=$jscomp.makeIterator(a);for(var f;!(f=a.next()).done;)f=f.value,this.set(f[0],f[1])}};c.prototype.set=function(a,c){var f=g(this,a);f.list||(f.list=this.data_[f.id]=[]);f.entry?f.entry.value=c:(f.entry={next:this.head_,previous:this.head_.previous,head:this.head_,key:a,value:c},f.list.push(f.entry),this.head_.previous.next=f.entry,this.head_.previous=f.entry,this.size++);return this};c.prototype.delete=
-function(a){a=g(this,a);return a.entry&&a.list?(a.list.splice(a.index,1),a.list.length||delete this.data_[a.id],a.entry.previous.next=a.entry.next,a.entry.next.previous=a.entry.previous,a.entry.head=null,this.size--,!0):!1};c.prototype.clear=function(){this.data_={};this.head_=this.head_.previous=t();this.size=0};c.prototype.has=function(a){return!!g(this,a).entry};c.prototype.get=function(a){return(a=g(this,a).entry)&&a.value};c.prototype.entries=function(){return p(this,function(a){return[a.key,
-a.value]})};c.prototype.keys=function(){return p(this,function(a){return a.key})};c.prototype.values=function(){return p(this,function(a){return a.value})};c.prototype.forEach=function(a,c){for(var h=this.entries(),f;!(f=h.next()).done;)f=f.value,a.call(c,f[1],f[0],this)};c.prototype[Symbol.iterator]=c.prototype.entries;var g=function(a,c){var f=c&&typeof c;"object"==f||"function"==f?h.has(c)?f=h.get(c):(f=""+ ++y,h.set(c,f)):f="p_"+c;var g=a.data_[f];if(g&&$jscomp.owns(a.data_,f))for(a=0;a<g.length;a++){var p=
-g[a];if(c!==c&&p.key!==p.key||c===p.key)return{id:f,list:g,index:a,entry:p}}return{id:f,list:g,index:-1,entry:void 0}},p=function(a,c){var f=a.head_;return $jscomp.iteratorPrototype(function(){if(f){for(;f.head!=a.head_;)f=f.previous;for(;f.next!=f.head;)return f=f.next,{done:!1,value:c(f)};f=null}return{done:!0,value:void 0}})},t=function(){var a={};return a.previous=a.next=a.head=a},y=0;return c},"es6","es3");
-$jscomp.polyfill("Object.is",function(a){return a?a:function(a,c){return a===c?0!==a||1/a===1/c:a!==a&&c!==c}},"es6","es3");$jscomp.polyfill("Array.prototype.includes",function(a){return a?a:function(a,c){var h=this;h instanceof String&&(h=String(h));var p=h.length;for(c=c||0;c<p;c++)if(h[c]==a||Object.is(h[c],a))return!0;return!1}},"es7","es3");
-$jscomp.checkStringArgs=function(a,h,c){if(null==a)throw new TypeError("The 'this' value for String.prototype."+c+" must not be null or undefined");if(h instanceof RegExp)throw new TypeError("First argument to String.prototype."+c+" must not be a regular expression");return a+""};$jscomp.polyfill("String.prototype.includes",function(a){return a?a:function(a,c){return-1!==$jscomp.checkStringArgs(this,a,"includes").indexOf(a,c||0)}},"es6","es3");
-(function(a,h){"function"===typeof define&&define.amd?define([],h):"object"===typeof module&&module.exports?module.exports=h():a.anime=h()})(this,function(){function a(b){try{return document.querySelectorAll(b)}catch(e){}}function h(b,e){for(var a=b.length,d=2<=arguments.length?arguments[1]:void 0,l=[],c=0;c<a;c++)if(c in b){var f=b[c];e.call(d,f,c,b)&&l.push(f)}return l}function c(b){return b.reduce(function(b,a){return b.concat(m.arr(a)?c(a):a)},[])}function g(b){if(m.arr(b))return b;m.str(b)&&
-(b=a(b)||b);return b instanceof NodeList||b instanceof HTMLCollection?[].slice.call(b):[b]}function p(b,e){return b.some(function(b){return b===e})}function t(b){var e={},a;for(a in b)e[a]=b[a];return e}function y(b,e){var a=t(b),d;for(d in b)a[d]=e.hasOwnProperty(d)?e[d]:b[d];return a}function f(b,e){var a=t(b),d;for(d in e)a[d]=m.und(b[d])?e[d]:b[d];return a}function W(b){b=b.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(b,a,e,n){return a+a+e+e+n+n});var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(b);
-b=parseInt(e[1],16);var a=parseInt(e[2],16);e=parseInt(e[3],16);return"rgba("+b+","+a+","+e+",1)"}function I(b){function a(b,a,e){0>e&&(e+=1);1<e&&--e;return e<1/6?b+6*(a-b)*e:.5>e?a:e<2/3?b+(a-b)*(2/3-e)*6:b}var n=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(b)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(b);b=parseInt(n[1],10)/360;var d=parseInt(n[2],10)/100,l=parseInt(n[3],10)/100;n=n[4]||1;if(0==d)l=d=b=l;else{var c=.5>l?l*(1+d):l+d-l*d,f=2*l-c;l=a(f,c,b+1/3);d=a(f,c,b);b=a(f,
-c,b-1/3)}return"rgba("+255*l+","+255*d+","+255*b+","+n+")"}function x(b){if(b=/([\+\-]?[0-9#\.]+)(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(b))return b[2]}function D(b,a){return m.fnc(b)?b(a.target,a.id,a.total):b}function K(b,a){if(a in b.style)return b.style[a]||getComputedStyle(b).getPropertyValue(a.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase())||"0"}function E(b,a){if(m.dom(b)&&p(X,a))return"transform";if(m.dom(b)&&(b.getAttribute(a)||m.svg(b)&&b[a]))return"attribute";
-if(m.dom(b)&&"transform"!==a&&K(b,a))return"css";if(null!=b[a])return"object"}function L(b){if(m.dom(b)){b=b.style.transform||"";for(var a=/(\w+)\(([^)]*)\)/g,n=new Map,d;d=a.exec(b);)n.set(d[1],d[2]);return n}}function F(b,a,n){switch(E(b,a)){case "transform":if(-1<a.indexOf("scale"))var e=1;else e=-1<a.indexOf("translate")||"perspective"===a?"px":-1<a.indexOf("rotate")||-1<a.indexOf("skew")?"deg":void 0,e=0+e;b=L(b).get(a)||e;n.transforms.list.set(a,b);n.transforms.last=a;return b;case "css":return K(b,
-a);case "attribute":return b.getAttribute(a);default:return b[a]||0}}function G(b,a){var e=/^(\*=|\+=|-=)/.exec(b);if(!e)return b;var d=x(b)||0;a=parseFloat(a);b=parseFloat(b.replace(e[0],""));switch(e[0][0]){case "+":return a+b+d;case "-":return a-b+d;case "*":return a*b+d}}function M(b,a){if(m.col(b))return b=m.rgb(b)?(a=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(b))?"rgba("+a[1]+",1)":b:m.hex(b)?W(b):m.hsl(b)?I(b):void 0,b;var e=x(b);e=e?b.substr(0,b.length-e.length):b;return a&&!/\s/g.test(b)?e+a:
-e}function H(b,a){return Math.sqrt(Math.pow(a.x-b.x,2)+Math.pow(a.y-b.y,2))}function N(b){b=b.points;for(var a=0,n,d=0;d<b.numberOfItems;d++){var l=b.getItem(d);0<d&&(a+=H(n,l));n=l}return a}function O(b){if(b.getTotalLength)return b.getTotalLength();switch(b.tagName.toLowerCase()){case "circle":return 2*Math.PI*b.getAttribute("r");case "rect":return 2*b.getAttribute("width")+2*b.getAttribute("height");case "line":return H({x:b.getAttribute("x1"),y:b.getAttribute("y1")},{x:b.getAttribute("x2"),y:b.getAttribute("y2")});
-case "polyline":return N(b);case "polygon":var a=b.points;return N(b)+H(a.getItem(a.numberOfItems-1),a.getItem(0))}}function Y(b,a){function e(e){e=void 0===e?0:e;return b.el.getPointAtLength(1<=a+e?a+e:0)}var d=e(),l=e(-1),c=e(1);switch(b.property){case "x":return d.x;case "y":return d.y;case "angle":return 180*Math.atan2(c.y-l.y,c.x-l.x)/Math.PI}}function P(b,a){var e=/-?\d*\.?\d+/g,d=M(m.pth(b)?b.totalLength:b,a)+"";return{original:d,numbers:d.match(e)?d.match(e).map(Number):[0],strings:m.str(b)||
-a?d.split(e):[]}}function Q(b){b=b?c(m.arr(b)?b.map(g):g(b)):[];return h(b,function(b,a,d){return d.indexOf(b)===a})}function R(b){var a=Q(b);return a.map(function(b,e){return{target:b,id:e,total:a.length,transforms:{list:L(b)}}})}function Z(b,a){var e=t(a);if(m.arr(b)){var d=b.length;2!==d||m.obj(b[0])?m.fnc(a.duration)||(e.duration=a.duration/d):b={value:b}}return(m.arr(b)?b:[b]).map(function(b,e){e=e?0:a.delay;b=m.obj(b)&&!m.pth(b)?b:{value:b};m.und(b.delay)&&(b.delay=e);return b}).map(function(b){return f(b,
-e)})}function aa(b,a){var e={},d;for(d in b){var c=D(b[d],a);m.arr(c)&&(c=c.map(function(b){return D(b,a)}),1===c.length&&(c=c[0]));e[d]=c}e.duration=parseFloat(e.duration);e.delay=parseFloat(e.delay);return e}function ba(b){return m.arr(b)?z.apply(this,b):S[b]}function ca(b,a){var e;return b.tweens.map(function(d){d=aa(d,a);var c=d.value,n=F(a.target,b.name,a),f=e?e.to.original:n;f=m.arr(c)?c[0]:f;var h=G(m.arr(c)?c[1]:c,f);n=x(h)||x(f)||x(n);d.from=P(f,n);d.to=P(h,n);d.start=e?e.end:b.offset;d.end=
-d.start+d.delay+d.duration+d.endDelay;d.easing=ba(d.easing);d.elasticity=(1E3-Math.min(Math.max(d.elasticity,1),999))/1E3;d.isPath=m.pth(c);d.isColor=m.col(d.from.original);d.isColor&&(d.round=1);return e=d})}function da(b,a){return h(c(b.map(function(b){return a.map(function(a){var e=E(b.target,a.name);if(e){var d=ca(a,b);a={type:e,property:a.name,animatable:b,tweens:d,duration:d[d.length-1].end,delay:d[0].delay}}else a=void 0;return a})})),function(b){return!m.und(b)})}function T(b,a,c,d){var e=
-"delay"===b;return a.length?(e?Math.min:Math.max).apply(Math,a.map(function(a){return a[b]})):e?d.delay:c.timeOffset+d.delay+d.duration}function ea(b){var a=y(fa,b),c=y(U,b),d=R(b.targets),l=[],h=f(a,c),g;for(g in b)h.hasOwnProperty(g)||"targets"===g||l.push({name:g,offset:h.timeOffset,tweens:Z(b[g],c)});b=da(d,l);return f(a,{children:[],animatables:d,animations:b,duration:T("duration",b,a,c),delay:T("delay",b,a,c)})}function r(b){function a(){return window.Promise&&new Promise(function(b){return t=
-b})}function c(){k.reversed=!k.reversed;k.children.forEach(function(b){return b.reversed=k.reversed})}function d(b){return k.reversed?k.duration-b:b}function f(b){for(var a=0,e=k.animations,d=e.length;a<d;){var c=e[a],f=c.animatable,n=c.tweens,l=n.length-1,g=n[l];l&&(g=h(n,function(a){return b<a.end})[0]||g);n=Math.min(Math.max(b-g.start-g.delay,0),g.duration)/g.duration;var m=isNaN(n)?1:g.easing(n,g.elasticity);n=g.to.strings;var u=g.round;l=[];var q=void 0;q=g.to.numbers.length;for(var p=0;p<q;p++){var w=
-void 0;w=g.to.numbers[p];var J=g.from.numbers[p];w=g.isPath?Y(g.value,m*w):J+m*(w-J);u&&(g.isColor&&2<p||(w=Math.round(w*u)/u));l.push(w)}if(g=n.length)for(q=n[0],m=0;m<g;m++)u=n[m+1],p=l[m],isNaN(p)||(q=u?q+(p+u):q+(p+" "));else q=l[0];V[c.type](f.target,c.property,q,f.transforms);c.currentValue=q;a++}k.currentTime=b;k.progress=b/k.duration*100}function g(b){if(k[b])k[b](k)}function m(){k.remaining&&!0!==k.remaining&&k.remaining--}function q(b,e){var n=k.timeOffset,l=k.duration,h=d(b);if(k.children.length){var q=
-k.children,w=q.length;if(!e||h>=k.currentTime)for(e=0;e<w;e++)q[e].seek(h);else for(;w--;)q[w].seek(h)}if(h>=n+k.delay||!l)k.began||(k.began=!0,g("begin")),g("run");if(h>n&&h<l)f(h);else if(h<=n&&0!==k.currentTime&&(f(0),k.reversed&&m()),h>=l&&k.currentTime!==l||!l)f(l),k.reversed||m();g("update");b>=l&&(k.remaining?(u=p,"alternate"===k.direction&&c()):(k.paused=!0,k.completed||(k.completed=!0,g("complete"),"Promise"in window&&(t(),x=a()))),A=0)}b=void 0===b?{}:b;var p,u,A=0,t=null,x=a(),k=ea(b);
-k.reset=function(){var b=k.direction,a=k.loop;k.currentTime=0;k.progress=0;k.paused=!0;k.began=!1;k.completed=!1;k.reversed="reverse"===b;k.remaining="alternate"===b&&1===a?2:a;f(0);for(b=k.children.length;b--;)k.children[b].reset()};k.tick=function(b){p=b;u||(u=p);q((A+p-u)*r.speed)};k.seek=function(b){q(d(b),!0)};k.pause=function(){k.paused=!0;var b=v.indexOf(k);-1<b&&v.splice(b,1)};k.play=function(){k.paused&&(k.paused=!1,u=0,A=d(k.currentTime),v.push(k),B||ha())};k.reverse=function(){c();u=0;
-A=d(k.currentTime)};k.restart=function(){k.pause();k.reset();k.play()};k.finished=x;k.reset();k.autoplay&&k.play();return k}var fa={update:void 0,begin:void 0,run:void 0,complete:void 0,loop:1,direction:"normal",autoplay:!0,timeOffset:0},U={duration:1E3,delay:0,endDelay:0,easing:"easeOutElastic",elasticity:500,round:0},X="translateX translateY translateZ rotate rotateX rotateY rotateZ scale scaleX scaleY scaleZ skew skewX skewY perspective".split(" "),m={arr:function(b){return Array.isArray(b)},obj:function(b){return-1<
-Object.prototype.toString.call(b).indexOf("Object")},pth:function(b){return m.obj(b)&&b.hasOwnProperty("totalLength")},svg:function(b){return b instanceof SVGElement},dom:function(b){return b.nodeType||m.svg(b)},str:function(b){return"string"===typeof b},fnc:function(b){return"function"===typeof b},und:function(b){return"undefined"===typeof b},hex:function(b){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(b)},rgb:function(b){return/^rgb/.test(b)},hsl:function(b){return/^hsl/.test(b)},col:function(b){return m.hex(b)||
-m.rgb(b)||m.hsl(b)}},z=function(){function b(b,a,d){return(((1-3*d+3*a)*b+(3*d-6*a))*b+3*a)*b}return function(a,c,d,f){if(0<=a&&1>=a&&0<=d&&1>=d){var e=new Float32Array(11);if(a!==c||d!==f)for(var n=0;11>n;++n)e[n]=b(.1*n,a,d);return function(n){if(a===c&&d===f)return n;if(0===n)return 0;if(1===n)return 1;for(var g=0,l=1;10!==l&&e[l]<=n;++l)g+=.1;--l;l=g+(n-e[l])/(e[l+1]-e[l])*.1;var h=3*(1-3*d+3*a)*l*l+2*(3*d-6*a)*l+3*a;if(.001<=h){for(g=0;4>g;++g){h=3*(1-3*d+3*a)*l*l+2*(3*d-6*a)*l+3*a;if(0===h)break;
-var m=b(l,a,d)-n;l-=m/h}n=l}else if(0===h)n=l;else{l=g;g+=.1;var p=0;do m=l+(g-l)/2,h=b(m,a,d)-n,0<h?g=m:l=m;while(1e-7<Math.abs(h)&&10>++p);n=m}return b(n,c,f)}}}}(),S=function(){function b(b,a){return 0===b||1===b?b:-Math.pow(2,10*(b-1))*Math.sin(2*(b-1-a/(2*Math.PI)*Math.asin(1))*Math.PI/a)}var a="Quad Cubic Quart Quint Sine Expo Circ Back Elastic".split(" "),c={In:[[.55,.085,.68,.53],[.55,.055,.675,.19],[.895,.03,.685,.22],[.755,.05,.855,.06],[.47,0,.745,.715],[.95,.05,.795,.035],[.6,.04,.98,
-.335],[.6,-.28,.735,.045],b],Out:[[.25,.46,.45,.94],[.215,.61,.355,1],[.165,.84,.44,1],[.23,1,.32,1],[.39,.575,.565,1],[.19,1,.22,1],[.075,.82,.165,1],[.175,.885,.32,1.275],function(a,e){return 1-b(1-a,e)}],InOut:[[.455,.03,.515,.955],[.645,.045,.355,1],[.77,0,.175,1],[.86,0,.07,1],[.445,.05,.55,.95],[1,0,0,1],[.785,.135,.15,.86],[.68,-.55,.265,1.55],function(a,e){return.5>a?b(2*a,e)/2:1-b(-2*a+2,e)/2}]},d={linear:z(.25,.25,.75,.75)},f={},g;for(g in c)f.type=g,c[f.type].forEach(function(b){return function(e,
-c){d["ease"+b.type+a[c]]=m.fnc(e)?e:z.apply($jscomp$this,e)}}(f)),f={type:f.type};return d}(),V={css:function(b,a,c){return b.style[a]=c},attribute:function(b,a,c){return b.setAttribute(a,c)},object:function(b,a,c){return b[a]=c},transform:function(b,a,c,d,f){d.list.set(a,c);if(a===d.last||f){a="";d=$jscomp.makeIterator(d.list);for(c=d.next();!c.done;c=d.next())f=$jscomp.makeIterator(c.value),c=f.next().value,f=f.next().value,a+=c+"("+f+") ";b.style.transform=a}}},v=[],C=[],B=0,ha=function(){function b(){B=
-requestAnimationFrame(a)}function a(a){C.length&&(v=h(v,function(b){return!C.includes(b)}),C=[]);if(v.length){for(var c=0;c<v.length;){var e=v[c];e.paused?C.push(e):v[c].tick(a);c++}b()}else cancelAnimationFrame(B),B=0}return b}();r.version="3.0.0";r.speed=1;r.running=v;r.remove=function(b){b=Q(b);for(var a=v.length;a--;)for(var c=v[a],d=c.animations,f=d.length;f--;)p(b,d[f].animatable.target)&&(d.splice(f,1),d.length||c.pause())};r.get=F;r.set=function(a,c){R(a).forEach(function(a){for(var b in c){var e=
-c[b],f=F(a.target,b,a),g=x(e)||x(f);e=G(M(e,g),f);f=E(a.target,b);V[f](a.target,b,e,a.transforms,!0)}})};r.path=function(b,c){var e=m.str(b)?a(b)[0]:b,d=c||100;return function(a){return{el:e,property:a,totalLength:O(e)*(d/100)}}};r.setDashoffset=function(a){var b=O(a);a.setAttribute("stroke-dasharray",b);return b};r.bezier=z;r.easings=S;r.timeline=function(a){a=void 0===a?{}:a;var b=r(a);b.pause();b.duration=0;b.add=function(c,d){b.children.forEach(function(a){a.began=!0;a.completed=!0});var e=f(c,
-y(U,a));e.targets=e.targets||a.targets;c=b.duration;e.autoplay=!1;e.direction=b.direction;e.timeOffset=m.und(d)?c:G(d,c);b.began=!0;b.completed=!0;b.seek(e.timeOffset);d=r(e);d.began=!0;d.completed=!0;d.duration>c&&(b.duration=d.duration);b.children.push(d);b.seek(0);b.reset();b.autoplay&&b.restart();return b};return b};r.random=function(a,c){return Math.floor(Math.random()*(c-a+1))+a};return r});
\ No newline at end of file
+(function(b,e){"function"===typeof define&&define.amd?define([],e):"object"===typeof module&&module.exports?module.exports=e():b.anime=e()})(this,function(){function b(a){return a.replace(/[^\d.-]/g," ").split(" ").filter(function(a){return""!==a&&"-"!==a}).map(function(a){return parseFloat(a)})}function e(a,c){function g(a){var d=c?c*a/1E3:a;d=1>h?Math.exp(-d*h*e)*(1*Math.cos(r*d)+k*Math.sin(r*d)):(1+k*d)*Math.exp(-d*e);return 0===a||1===a?a:1-d}function d(){for(var a=1/6,c=0,d=0;;)if(c+=a,1===g(c)){if(d++,
+16<=d)break}else d=0;return c*a*1E3}var m=$jscomp.makeIterator(b(a));a=m.next().value;a=void 0===a?1:a;var p=m.next().value;p=void 0===p?100:p;var f=m.next().value;f=void 0===f?10:f;m=m.next().value;m=void 0===m?0:m;var e=Math.sqrt(p/a),h=f/(2*Math.sqrt(p*a)),r=1>h?e*Math.sqrt(1-h*h):0,k=1>h?(h*e+-m)/r:-m+e;return c?g:d}function h(a,c){a=void 0===a?1:a;c=void 0===c?.5:c;return function(g){var d=c/(2*Math.PI)*Math.asin(1/a);return 0===g||1===g?g:-(a*Math.pow(2,10*--g)*Math.sin(2*(g-d)*Math.PI/c))}}
+function n(a){return function(c){1/a*Math.round(percentComplete*a)*(endValue-startValue)}}function u(a){var c=a.easing,g=c.split("(")[0],d=b(c),m=L[g];switch(g){case "spring":return e(c,a.duration);case "cubic-bezier":return F.apply(this,d);case "step":return n.apply(this,d);default:return k.fnc(m)?m.apply(this,d):F.apply(this,m)}}function v(a){try{return document.querySelectorAll(a)}catch(c){}}function A(a,c){for(var g=a.length,d=2<=arguments.length?arguments[1]:void 0,b=[],p=0;p<g;p++)if(p in a){var f=
+a[p];c.call(d,f,p,a)&&b.push(f)}return b}function f(a){return a.reduce(function(a,g){return a.concat(k.arr(g)?f(g):g)},[])}function q(a){if(k.arr(a))return a;k.str(a)&&(a=v(a)||a);return a instanceof NodeList||a instanceof HTMLCollection?[].slice.call(a):[a]}function x(a,c){return a.some(function(a){return a===c})}function D(a){var c={},g;for(g in a)c[g]=a[g];return c}function B(a,c){var g=D(a),d;for(d in a)g[d]=c.hasOwnProperty(d)?c[d]:a[d];return g}function G(a,c){var g=D(a),d;for(d in c)g[d]=k.und(a[d])?
+c[d]:a[d];return g}function Z(a){a=a.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(a,c,g,b){return c+c+g+g+b+b});var c=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);a=parseInt(c[1],16);var g=parseInt(c[2],16);c=parseInt(c[3],16);return"rgba("+a+","+g+","+c+",1)"}function aa(a){function c(a,c,d){0>d&&(d+=1);1<d&&--d;return d<1/6?a+6*(c-a)*d:.5>d?c:d<2/3?a+(c-a)*(2/3-d)*6:a}var g=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(a)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(a);
+a=parseInt(g[1],10)/360;var d=parseInt(g[2],10)/100,b=parseInt(g[3],10)/100;g=g[4]||1;if(0==d)b=d=a=b;else{var p=.5>b?b*(1+d):b+d-b*d,f=2*b-p;b=c(f,p,a+1/3);d=c(f,p,a);a=c(f,p,a-1/3)}return"rgba("+255*b+","+255*d+","+255*a+","+g+")"}function y(a){if(a=/([\+\-]?[0-9#\.]+)(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(a))return a[2]}function M(a,c){return k.fnc(a)?a(c.target,c.id,c.total):a}function N(a,c){if(c in a.style)return a.style[c]||getComputedStyle(a).getPropertyValue(c.replace(/([a-z])([A-Z])/g,
+"$1-$2").toLowerCase())||"0"}function H(a,c){if(k.dom(a)&&x(ba,c))return"transform";if(k.dom(a)&&(a.getAttribute(c)||k.svg(a)&&a[c]))return"attribute";if(k.dom(a)&&"transform"!==c&&N(a,c))return"css";if(null!=a[c])return"object"}function O(a){if(k.dom(a)){a=a.style.transform||"";for(var c=/(\w+)\(([^)]*)\)/g,g=new Map,d;d=c.exec(a);)g.set(d[1],d[2]);return g}}function I(a,c,g){switch(H(a,c)){case "transform":if(-1<c.indexOf("scale"))var d=1;else d=-1<c.indexOf("translate")||"perspective"===c?"px":
+-1<c.indexOf("rotate")||-1<c.indexOf("skew")?"deg":void 0,d=0+d;a=O(a).get(c)||d;g.transforms.list.set(c,a);g.transforms.last=c;return a;case "css":return N(a,c);case "attribute":return a.getAttribute(c);default:return a[c]||0}}function J(a,c){var g=/^(\*=|\+=|-=)/.exec(a);if(!g)return a;var d=y(a)||0;c=parseFloat(c);a=parseFloat(a.replace(g[0],""));switch(g[0][0]){case "+":return c+a+d;case "-":return c-a+d;case "*":return c*a+d}}function P(a,c){if(k.col(a))return a=k.rgb(a)?(c=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(a))?
+"rgba("+c[1]+",1)":a:k.hex(a)?Z(a):k.hsl(a)?aa(a):void 0,a;var g=y(a);g=g?a.substr(0,a.length-g.length):a;return c&&!/\s/g.test(a)?g+c:g}function K(a,c){return Math.sqrt(Math.pow(c.x-a.x,2)+Math.pow(c.y-a.y,2))}function Q(a){a=a.points;for(var c=0,g,d=0;d<a.numberOfItems;d++){var b=a.getItem(d);0<d&&(c+=K(g,b));g=b}return c}function R(a){if(a.getTotalLength)return a.getTotalLength();switch(a.tagName.toLowerCase()){case "circle":return 2*Math.PI*a.getAttribute("r");case "rect":return 2*a.getAttribute("width")+
+2*a.getAttribute("height");case "line":return K({x:a.getAttribute("x1"),y:a.getAttribute("y1")},{x:a.getAttribute("x2"),y:a.getAttribute("y2")});case "polyline":return Q(a);case "polygon":var c=a.points;return Q(a)+K(c.getItem(c.numberOfItems-1),c.getItem(0))}}function ca(a,c){function g(d){d=void 0===d?0:d;return a.el.getPointAtLength(1<=c+d?c+d:0)}var d=g(),b=g(-1),f=g(1);switch(a.property){case "x":return d.x;case "y":return d.y;case "angle":return 180*Math.atan2(f.y-b.y,f.x-b.x)/Math.PI}}function S(a,
+c){var b=/-?\d*\.?\d+/g,d=P(k.pth(a)?a.totalLength:a,c)+"";return{original:d,numbers:d.match(b)?d.match(b).map(Number):[0],strings:k.str(a)||c?d.split(b):[]}}function T(a){a=a?f(k.arr(a)?a.map(q):q(a)):[];return A(a,function(a,b,d){return d.indexOf(a)===b})}function U(a){var c=T(a);return c.map(function(a,d){return{target:a,id:d,total:c.length,transforms:{list:O(a)}}})}function da(a,c){var b=D(c);/^spring/.test(b.easing)&&(b.duration=e(b.easing));if(k.arr(a)){var d=a.length;2!==d||k.obj(a[0])?k.fnc(c.duration)||
+(b.duration=c.duration/d):a={value:a}}return(k.arr(a)?a:[a]).map(function(a,d){a=k.obj(a)&&!k.pth(a)?a:{value:a};k.und(a.delay)&&(a.delay=d?0:c.delay);return a}).map(function(a){return G(a,b)})}function ea(a,c){var b={},d;for(d in a){var m=M(a[d],c);k.arr(m)&&(m=m.map(function(a){return M(a,c)}),1===m.length&&(m=m[0]));b[d]=m}b.duration=parseFloat(b.duration);b.delay=parseFloat(b.delay);return b}function fa(a,c){var b;return a.tweens.map(function(d){d=ea(d,c);var g=d.value,f=I(c.target,a.name,c),
+e=b?b.to.original:f;e=k.arr(g)?g[0]:e;var h=J(k.arr(g)?g[1]:g,e);f=y(h)||y(e)||y(f);d.from=S(e,f);d.to=S(h,f);d.start=b?b.end:a.offset;d.end=d.start+d.delay+d.duration+d.endDelay;d.easing=u(d);d.isPath=k.pth(g);d.isColor=k.col(d.from.original);d.isColor&&(d.round=1);return b=d})}function ha(a,c){return A(f(a.map(function(a){return c.map(function(c){var b=H(a.target,c.name);if(b){var d=fa(c,a);c={type:b,property:c.name,animatable:a,tweens:d,duration:d[d.length-1].end,delay:d[0].delay}}else c=void 0;
+return c})})),function(a){return!k.und(a)})}function V(a,c,b,d){var g="delay"===a;return c.length?(g?Math.min:Math.max).apply(Math,c.map(function(c){return c[a]})):g?d.delay:b.timeOffset+d.delay+d.duration}function ia(a){var c=B(ja,a),b=B(W,a),d=U(a.targets),f=[],e;for(e in a)c.hasOwnProperty(e)||b.hasOwnProperty(e)||"targets"===e||f.push({name:e,offset:c.timeOffset,tweens:da(a[e],b)});a=ha(d,f);return G(c,{children:[],animatables:d,animations:a,duration:V("duration",a,c,b),delay:V("delay",a,c,b)})}
+function t(a){function c(){return window.Promise&&new Promise(function(a){return u=a})}function b(){l.reversed=!l.reversed;l.children.forEach(function(a){return a.reversed=l.reversed})}function d(a){return l.reversed?l.duration-a:a}function f(a){for(var c=0,b=l.animations,d=b.length;c<d;){var g=b[c],f=g.animatable,e=g.tweens,m=e.length-1,h=e[m];m&&(h=A(e,function(c){return a<c.end})[0]||h);e=Math.min(Math.max(a-h.start-h.delay,0),h.duration)/h.duration;var k=isNaN(e)?1:h.easing(e);e=h.to.strings;
+var p=h.round;m=[];var n=void 0;n=h.to.numbers.length;for(var r=0;r<n;r++){var q=void 0;q=h.to.numbers[r];var z=h.from.numbers[r];q=h.isPath?ca(h.value,k*q):z+k*(q-z);p&&(h.isColor&&2<r||(q=Math.round(q*p)/p));m.push(q)}if(h=e.length)for(n=e[0],k=0;k<h;k++)p=e[k+1],r=m[k],isNaN(r)||(n=p?n+(r+p):n+(r+" "));else n=m[0];X[g.type](f.target,g.property,n,f.transforms);g.currentValue=n;c++}l.currentTime=a;l.progress=a/l.duration*100}function e(a){if(l[a])l[a](l)}function h(){l.remaining&&!0!==l.remaining&&
+l.remaining--}function k(a,g){var m=l.timeOffset,k=l.duration,p=d(a);if(l.children.length){var z=l.children,E=z.length;if(!g||p>=l.currentTime)for(g=0;g<E;g++)z[g].seek(p);else for(;E--;)z[E].seek(p)}if(p>=m+l.delay||!k)l.began||(l.began=!0,e("begin")),e("run");if(p>m&&p<k)f(p);else if(p<=m&&0!==l.currentTime&&(f(0),l.reversed&&h()),p>=k&&l.currentTime!==k||!k)f(k),l.reversed||h();e("update");a>=k&&(l.remaining?(r=n,"alternate"===l.direction&&b()):(l.paused=!0,l.completed||(l.completed=!0,e("complete"),
+"Promise"in window&&(u(),v=c()))),q=0)}a=void 0===a?{}:a;var n,r,q=0,u=null,v=c(),l=ia(a);l.reset=function(){var a=l.direction,c=l.loop;l.currentTime=0;l.progress=0;l.paused=!0;l.began=!1;l.completed=!1;l.reversed="reverse"===a;l.remaining="alternate"===a&&1===c?2:c;f(0);for(a=l.children.length;a--;)l.children[a].reset()};l.tick=function(a){n=a;r||(r=n);k((q+n-r)*t.speed)};l.seek=function(a){k(d(a),!0)};l.pause=function(){l.paused=!0};l.play=function(){l.paused&&(l.paused=!1,r=0,q=d(l.currentTime),
+w.push(l),C||ka())};l.reverse=function(){b();r=0;q=d(l.currentTime)};l.restart=function(){l.pause();l.reset();l.play()};l.finished=v;l.reset();l.autoplay&&l.play();return l}function Y(a,c){for(var b=c.length;b--;)x(a,c[b].animatable.target)&&c.splice(b,1)}var ja={update:void 0,begin:void 0,run:void 0,complete:void 0,loop:1,direction:"normal",autoplay:!0,timeOffset:0},W={duration:1E3,delay:0,endDelay:0,easing:"out-elastic",round:0},ba="translateX translateY translateZ rotate rotateX rotateY rotateZ scale scaleX scaleY scaleZ skew skewX skewY perspective".split(" "),
+k={arr:function(a){return Array.isArray(a)},obj:function(a){return-1<Object.prototype.toString.call(a).indexOf("Object")},pth:function(a){return k.obj(a)&&a.hasOwnProperty("totalLength")},svg:function(a){return a instanceof SVGElement},dom:function(a){return a.nodeType||k.svg(a)},str:function(a){return"string"===typeof a},fnc:function(a){return"function"===typeof a},und:function(a){return"undefined"===typeof a},hex:function(a){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(a)},rgb:function(a){return/^rgb/.test(a)},
+hsl:function(a){return/^hsl/.test(a)},col:function(a){return k.hex(a)||k.rgb(a)||k.hsl(a)}},F=function(){function a(a,b,d){return(((1-3*d+3*b)*a+(3*d-6*b))*a+3*b)*a}return function(c,b,d,f){if(0<=c&&1>=c&&0<=d&&1>=d){var g=new Float32Array(11);if(c!==b||d!==f)for(var e=0;11>e;++e)g[e]=a(.1*e,c,d);return function(e){if(c===b&&d===f||0===e||1===e)return e;for(var h=0,m=1;10!==m&&g[m]<=e;++m)h+=.1;--m;m=h+(e-g[m])/(g[m+1]-g[m])*.1;var k=3*(1-3*d+3*c)*m*m+2*(3*d-6*c)*m+3*c;if(.001<=k){for(h=0;4>h;++h){k=
+3*(1-3*d+3*c)*m*m+2*(3*d-6*c)*m+3*c;if(0===k)break;var p=a(m,c,d)-e;m-=p/k}e=m}else if(0===k)e=m;else{m=h;h+=.1;var n=0;do p=m+(h-m)/2,k=a(p,c,d)-e,0<k?h=p:m=p;while(1e-7<Math.abs(k)&&10>++n);e=p}return a(e,b,f)}}}}(),L=function(){var a="Quad Cubic Quart Quint Sine Expo Circ Back Elastic".split(" "),c={In:[[.55,.085,.68,.53],[.55,.055,.675,.19],[.895,.03,.685,.22],[.755,.05,.855,.06],[.47,0,.745,.715],[.95,.05,.795,.035],[.6,.04,.98,.335],[.6,-.28,.735,.045],h],Out:[[.25,.46,.45,.94],[.215,.61,.355,
+1],[.165,.84,.44,1],[.23,1,.32,1],[.39,.575,.565,1],[.19,1,.22,1],[.075,.82,.165,1],[.175,.885,.32,1.275],function(a,c){return function(b){return 1-h(a,c)(1-b)}}],InOut:[[.455,.03,.515,.955],[.645,.045,.355,1],[.77,0,.175,1],[.86,0,.07,1],[.445,.05,.55,.95],[1,0,0,1],[.785,.135,.15,.86],[.68,-.55,.265,1.55],function(a,c){return function(b){return.5>b?h(a,c)(2*b)/2:1-h(a,c)(-2*b+2)/2}}]},b={linear:[.25,.25,.75,.75]},d={},e;for(e in c)d.type=e,c[d.type].forEach(function(c){return function(d,g){b["ease"+
+c.type+a[g]]=d}}(d)),d={type:d.type};return b}(),X={css:function(a,c,b){return a.style[c]=b},attribute:function(a,c,b){return a.setAttribute(c,b)},object:function(a,c,b){return a[c]=b},transform:function(a,c,b,d,e){d.list.set(c,b);if(c===d.last||e){c="";d=$jscomp.makeIterator(d.list);for(b=d.next();!b.done;b=d.next())e=$jscomp.makeIterator(b.value),b=e.next().value,e=e.next().value,c+=b+"("+e+") ";a.style.transform=c}}},w=[],C,ka=function(){function a(){C=requestAnimationFrame(b)}function b(b){if(w.length){for(var c=
+0;c<w.length;){var e=w[c];e.paused?(e=w.indexOf(e),-1<e&&w.splice(e,1)):e.tick(b);c++}a()}else C=cancelAnimationFrame(C)}return a}();t.version="3.0.0";t.speed=1;t.running=w;t.remove=function(a){a=T(a);for(var b=w.length;b--;){var e=w[b],d=e.animations,f=e.children;Y(a,d);for(var h=f.length;h--;){var k=f[h],n=k.animations;Y(a,n);n.length||k.children.length||f.splice(h,1)}d.length||f.length||e.pause()}};t.get=I;t.set=function(a,b){U(a).forEach(function(a){for(var c in b){var e=b[c],f=I(a.target,c,a),
+g=y(e)||y(f);e=J(P(e,g),f);f=H(a.target,c);X[f](a.target,c,e,a.transforms,!0)}})};t.path=function(a,b){var c=k.str(a)?v(a)[0]:a,d=b||100;return function(a){return{el:c,property:a,totalLength:R(c)*(d/100)}}};t.setDashoffset=function(a){var b=R(a);a.setAttribute("stroke-dasharray",b);return b};t.bezier=F;t.easings=L;t.timeline=function(a){a=void 0===a?{}:a;var b=t(a);b.pause();b.duration=0;b.add=function(c,d){b.children.forEach(function(a){a.began=!0;a.completed=!0});var e=G(c,B(W,a));e.targets=e.targets||
+a.targets;c=b.duration;e.autoplay=!1;e.direction=b.direction;e.timeOffset=k.und(d)?c:J(d,c);b.began=!0;b.completed=!0;b.seek(e.timeOffset);d=t(e);d.began=!0;d.completed=!0;d.duration>c&&(b.duration=d.duration);b.children.push(d);b.seek(0);b.reset();b.autoplay&&b.restart();return b};return b};t.random=function(a,b){return Math.floor(Math.random()*(b-a+1))+a};return t});
\ No newline at end of file
diff --git a/documentation/assets/js/anime.3.0.0-alpha.js b/documentation/assets/js/anime.3.0.0-alpha.js
new file mode 100644
index 00000000..1dbb7070
--- /dev/null
+++ b/documentation/assets/js/anime.3.0.0-alpha.js
@@ -0,0 +1,1004 @@
+/**
+ * http://animejs.com
+ * JavaScript animation engine
+ * @version v3.0.0-alpha
+ * @author Julian Garnier
+ * @copyright ©2017 Julian Garnier
+ * Released under the MIT license
+**/
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module.
+ define([], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // Node. Does not work with strict CommonJS, but
+ // only CommonJS-like environments that support module.exports,
+ // like Node.
+ module.exports = factory();
+ } else {
+ // Browser globals (root is window)
+ root.anime = factory();
+ }
+}(this, () => {
+
+ // Defaults
+
+ const defaultInstanceSettings = {
+ update: undefined,
+ begin: undefined,
+ run: undefined,
+ complete: undefined,
+ loop: 1,
+ direction: 'normal',
+ autoplay: true,
+ timeOffset: 0
+ }
+
+ const defaultTweenSettings = {
+ duration: 1000,
+ delay: 0,
+ endDelay: 0,
+ easing: 'easeOutElastic',
+ elasticity: 500,
+ round: 0
+ }
+
+ const validTransforms = ['translateX', 'translateY', 'translateZ', 'rotate', 'rotateX', 'rotateY', 'rotateZ', 'scale', 'scaleX', 'scaleY', 'scaleZ', 'skew', 'skewX', 'skewY', 'perspective'];
+
+ // Utils
+
+ function stringContains(str, text) {
+ return str.indexOf(text) > -1;
+ }
+
+ const is = {
+ arr: a => Array.isArray(a),
+ obj: a => stringContains(Object.prototype.toString.call(a), 'Object'),
+ pth: a => is.obj(a) && a.hasOwnProperty('totalLength'),
+ svg: a => a instanceof SVGElement,
+ dom: a => a.nodeType || is.svg(a),
+ str: a => typeof a === 'string',
+ fnc: a => typeof a === 'function',
+ und: a => typeof a === 'undefined',
+ hex: a => /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(a),
+ rgb: a => /^rgb/.test(a),
+ hsl: a => /^hsl/.test(a),
+ col: a => (is.hex(a) || is.rgb(a) || is.hsl(a))
+ }
+
+ // BezierEasing https://github.com/gre/bezier-easing
+
+ const bezier = (() => {
+
+ const kSplineTableSize = 11;
+ const kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
+
+ function A (aA1, aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1 };
+ function B (aA1, aA2) { return 3.0 * aA2 - 6.0 * aA1 };
+ function C (aA1) { return 3.0 * aA1 };
+
+ function calcBezier (aT, aA1, aA2) { return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT };
+ function getSlope (aT, aA1, aA2) { return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1) };
+
+ function binarySubdivide (aX, aA, aB, mX1, mX2) {
+ let currentX, currentT, i = 0;
+ do {
+ currentT = aA + (aB - aA) / 2.0;
+ currentX = calcBezier(currentT, mX1, mX2) - aX;
+ if (currentX > 0.0) { aB = currentT } else { aA = currentT };
+ } while (Math.abs(currentX) > 0.0000001 && ++i < 10);
+ return currentT;
+ }
+
+ function newtonRaphsonIterate (aX, aGuessT, mX1, mX2) {
+ for (let i = 0; i < 4; ++i) {
+ const currentSlope = getSlope(aGuessT, mX1, mX2);
+ if (currentSlope === 0.0) return aGuessT;
+ const currentX = calcBezier(aGuessT, mX1, mX2) - aX;
+ aGuessT -= currentX / currentSlope;
+ }
+ return aGuessT;
+ }
+
+ function bezier(mX1, mY1, mX2, mY2) {
+
+ if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) return;
+ let sampleValues = new Float32Array(kSplineTableSize);
+
+ if (mX1 !== mY1 || mX2 !== mY2) {
+ for (let i = 0; i < kSplineTableSize; ++i) {
+ sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
+ }
+ }
+
+ function getTForX(aX) {
+
+ let intervalStart = 0.0;
+ let currentSample = 1;
+ const lastSample = kSplineTableSize - 1;
+
+ for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
+ intervalStart += kSampleStepSize;
+ }
+
+ --currentSample;
+
+ const dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
+ const guessForT = intervalStart + dist * kSampleStepSize;
+ const initialSlope = getSlope(guessForT, mX1, mX2);
+
+ if (initialSlope >= 0.001) {
+ return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
+ } else if (initialSlope === 0.0) {
+ return guessForT;
+ } else {
+ return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
+ }
+
+ }
+
+ return x => {
+ if (mX1 === mY1 && mX2 === mY2) return x;
+ if (x === 0) return 0;
+ if (x === 1) return 1;
+ return calcBezier(getTForX(x), mY1, mY2);
+ }
+
+ }
+
+ return bezier;
+
+ })();
+
+ const easings = (() => {
+
+ const names = ['Quad', 'Cubic', 'Quart', 'Quint', 'Sine', 'Expo', 'Circ', 'Back', 'Elastic'];
+
+ // Elastic easing adapted from jQueryUI http://api.jqueryui.com/easings/
+
+ function elastic(t, p) {
+ return t === 0 || t === 1 ? t :
+ -Math.pow(2, 10 * (t - 1)) * Math.sin((((t - 1) - (p / (Math.PI * 2.0) * Math.asin(1))) * (Math.PI * 2)) / p );
+ }
+
+ // Approximated Penner equations http://matthewlein.com/ceaser/
+
+ const equations = {
+ In: [
+ [0.550, 0.085, 0.680, 0.530], /* InQuad */
+ [0.550, 0.055, 0.675, 0.190], /* InCubic */
+ [0.895, 0.030, 0.685, 0.220], /* InQuart */
+ [0.755, 0.050, 0.855, 0.060], /* InQuint */
+ [0.470, 0.000, 0.745, 0.715], /* InSine */
+ [0.950, 0.050, 0.795, 0.035], /* InExpo */
+ [0.600, 0.040, 0.980, 0.335], /* InCirc */
+ [0.600, -0.280, 0.735, 0.045], /* InBack */
+ elastic /* InElastic */
+ ], Out: [
+ [0.250, 0.460, 0.450, 0.940], /* OutQuad */
+ [0.215, 0.610, 0.355, 1.000], /* OutCubic */
+ [0.165, 0.840, 0.440, 1.000], /* OutQuart */
+ [0.230, 1.000, 0.320, 1.000], /* OutQuint */
+ [0.390, 0.575, 0.565, 1.000], /* OutSine */
+ [0.190, 1.000, 0.220, 1.000], /* OutExpo */
+ [0.075, 0.820, 0.165, 1.000], /* OutCirc */
+ [0.175, 0.885, 0.320, 1.275], /* OutBack */
+ (t, f) => 1 - elastic(1 - t, f) /* OutElastic */
+ ], InOut: [
+ [0.455, 0.030, 0.515, 0.955], /* InOutQuad */
+ [0.645, 0.045, 0.355, 1.000], /* InOutCubic */
+ [0.770, 0.000, 0.175, 1.000], /* InOutQuart */
+ [0.860, 0.000, 0.070, 1.000], /* InOutQuint */
+ [0.445, 0.050, 0.550, 0.950], /* InOutSine */
+ [1.000, 0.000, 0.000, 1.000], /* InOutExpo */
+ [0.785, 0.135, 0.150, 0.860], /* InOutCirc */
+ [0.680, -0.550, 0.265, 1.550], /* InOutBack */
+ (t, f) => t < .5 ? elastic(t * 2, f) / 2 : 1 - elastic(t * -2 + 2, f) / 2 /* InOutElastic */
+ ]
+ }
+
+ let functions = {
+ linear: bezier(0.250, 0.250, 0.750, 0.750)
+ }
+
+ for (let type in equations) {
+ equations[type].forEach((f, i) => {
+ functions['ease'+type+names[i]] = is.fnc(f) ? f : bezier.apply(this, f);
+ });
+ }
+
+ return functions;
+
+ })();
+
+ // Strings
+
+ function stringToHyphens(str) {
+ return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
+ }
+
+ function selectString(str) {
+ try {
+ let nodes = document.querySelectorAll(str);
+ return nodes;
+ } catch(e) {
+ return;
+ }
+ }
+
+ // Arrays
+
+ function filterArray(arr, callback) {
+ const len = arr.length;
+ const thisArg = arguments.length >= 2 ? arguments[1] : void 0;
+ let result = [];
+ for (let i = 0; i < len; i++) {
+ if (i in arr) {
+ const val = arr[i];
+ if (callback.call(thisArg, val, i, arr)) {
+ result.push(val);
+ }
+ }
+ }
+ return result;
+ }
+
+ function flattenArray(arr) {
+ return arr.reduce((a, b) => a.concat(is.arr(b) ? flattenArray(b) : b), []);
+ }
+
+ function toArray(o) {
+ if (is.arr(o)) return o;
+ if (is.str(o)) o = selectString(o) || o;
+ if (o instanceof NodeList || o instanceof HTMLCollection) return [].slice.call(o);
+ return [o];
+ }
+
+ function arrayContains(arr, val) {
+ return arr.some(a => a === val);
+ }
+
+ // Objects
+
+ function cloneObject(o) {
+ let clone = {};
+ for (let p in o) clone[p] = o[p];
+ return clone;
+ }
+
+ function replaceObjectProps(o1, o2) {
+ let o = cloneObject(o1);
+ for (let p in o1) o[p] = o2.hasOwnProperty(p) ? o2[p] : o1[p];
+ return o;
+ }
+
+ function mergeObjects(o1, o2) {
+ let o = cloneObject(o1);
+ for (let p in o2) o[p] = is.und(o1[p]) ? o2[p] : o1[p];
+ return o;
+ }
+
+ // Colors
+
+ function rgbToRgba(rgbValue) {
+ const rgb = /rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(rgbValue);
+ return rgb ? `rgba(${rgb[1]},1)` : rgbValue;
+ }
+
+ function hexToRgba(hexValue) {
+ const rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
+ const hex = hexValue.replace(rgx, (m, r, g, b) => r + r + g + g + b + b );
+ const rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
+ const r = parseInt(rgb[1], 16);
+ const g = parseInt(rgb[2], 16);
+ const b = parseInt(rgb[3], 16);
+ return `rgba(${r},${g},${b},1)`;
+ }
+
+ function hslToRgba(hslValue) {
+ const hsl = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(hslValue) || /hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(hslValue);
+ const h = parseInt(hsl[1], 10) / 360;
+ const s = parseInt(hsl[2], 10) / 100;
+ const l = parseInt(hsl[3], 10) / 100;
+ const a = hsl[4] || 1;
+ function hue2rgb(p, q, t) {
+ if (t < 0) t += 1;
+ if (t > 1) t -= 1;
+ if (t < 1/6) return p + (q - p) * 6 * t;
+ if (t < 1/2) return q;
+ if (t < 2/3) return p + (q - p) * (2/3 - t) * 6;
+ return p;
+ }
+ let r, g, b;
+ if (s == 0) {
+ r = g = b = l;
+ } else {
+ const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
+ const p = 2 * l - q;
+ r = hue2rgb(p, q, h + 1/3);
+ g = hue2rgb(p, q, h);
+ b = hue2rgb(p, q, h - 1/3);
+ }
+ return `rgba(${r * 255},${g * 255},${b * 255},${a})`;
+ }
+
+ function colorToRgb(val) {
+ if (is.rgb(val)) return rgbToRgba(val);
+ if (is.hex(val)) return hexToRgba(val);
+ if (is.hsl(val)) return hslToRgba(val);
+ }
+
+ // Units
+
+ function getUnit(val) {
+ const split = /([\+\-]?[0-9#\.]+)(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(val);
+ if (split) return split[2];
+ }
+
+ function getTransformUnit(propName) {
+ if (stringContains(propName, 'translate') || propName === 'perspective') return 'px';
+ if (stringContains(propName, 'rotate') || stringContains(propName, 'skew')) return 'deg';
+ }
+
+ // Values
+
+ function minMaxValue(val, min, max) {
+ return Math.min(Math.max(val, min), max);
+ }
+
+ function getFunctionValue(val, animatable) {
+ if (!is.fnc(val)) return val;
+ return val(animatable.target, animatable.id, animatable.total);
+ }
+
+ function getCSSValue(el, prop) {
+ if (prop in el.style) {
+ return el.style[prop] || getComputedStyle(el).getPropertyValue(stringToHyphens(prop)) || '0';
+ }
+ }
+
+ function getAnimationType(el, prop) {
+ if (is.dom(el) && arrayContains(validTransforms, prop)) return 'transform';
+ if (is.dom(el) && (el.getAttribute(prop) || (is.svg(el) && el[prop]))) return 'attribute';
+ if (is.dom(el) && (prop !== 'transform' && getCSSValue(el, prop))) return 'css';
+ if (el[prop] != null) return 'object';
+ }
+
+ function getElementTransforms(el) {
+ if (!is.dom(el)) return;
+ const str = el.style.transform || '';
+ const reg = /(\w+)\(([^)]*)\)/g;
+ const transforms = new Map();
+ let m; while (m = reg.exec(str)) transforms.set(m[1], m[2]);
+ return transforms;
+ }
+
+ function getTransformValue(el, propName, animatable) {
+ const defaultVal = stringContains(propName, 'scale') ? 1 : 0 + getTransformUnit(propName);
+ const prop = getElementTransforms(el).get(propName) || defaultVal;
+ animatable.transforms.list.set(propName, prop);
+ animatable.transforms['last'] = propName;
+ return prop;
+ }
+
+ function getOriginalTargetValue(target, propName, animatable) {
+ switch (getAnimationType(target, propName)) {
+ case 'transform': return getTransformValue(target, propName, animatable);
+ case 'css': return getCSSValue(target, propName);
+ case 'attribute': return target.getAttribute(propName);
+ default: return target[propName] || 0;
+ }
+ }
+
+ function getRelativeValue(to, from) {
+ const operator = /^(\*=|\+=|-=)/.exec(to);
+ if (!operator) return to;
+ const u = getUnit(to) || 0;
+ const x = parseFloat(from);
+ const y = parseFloat(to.replace(operator[0], ''));
+ switch (operator[0][0]) {
+ case '+': return x + y + u;
+ case '-': return x - y + u;
+ case '*': return x * y + u;
+ }
+ }
+
+ function validateValue(val, unit) {
+ if (is.col(val)) return colorToRgb(val);
+ const originalUnit = getUnit(val);
+ const unitLess = originalUnit ? val.substr(0, val.length - originalUnit.length) : val;
+ return unit && !/\s/g.test(val) ? unitLess + unit : unitLess;
+ }
+
+ // getTotalLength() equivalent for circle, rect, polyline, polygon and line shapes.
+ // adapted from https://gist.github.com/SebLambla/3e0550c496c236709744
+
+ function getDistance(p1, p2) {
+ return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
+ }
+
+ function getCircleLength(el) {
+ return 2 * Math.PI * el.getAttribute('r');
+ }
+
+ function getRectLength(el) {
+ return (el.getAttribute('width') * 2) + (el.getAttribute('height') * 2);
+ }
+
+ function getLineLength(el) {
+ return getDistance(
+ {x: el.getAttribute('x1'), y: el.getAttribute('y1')},
+ {x: el.getAttribute('x2'), y: el.getAttribute('y2')}
+ );
+ }
+
+ function getPolylineLength(el) {
+ const points = el.points;
+ let totalLength = 0;
+ let previousPos;
+ for (let i = 0 ; i < points.numberOfItems; i++) {
+ const currentPos = points.getItem(i);
+ if (i > 0) totalLength += getDistance(previousPos, currentPos);
+ previousPos = currentPos;
+ }
+ return totalLength;
+ }
+
+ function getPolygonLength(el) {
+ const points = el.points;
+ return getPolylineLength(el) + getDistance(points.getItem(points.numberOfItems - 1), points.getItem(0));
+ }
+
+ // Path animation
+
+ function getTotalLength(el) {
+ if (el.getTotalLength) return el.getTotalLength();
+ switch(el.tagName.toLowerCase()) {
+ case 'circle': return getCircleLength(el);
+ case 'rect': return getRectLength(el);
+ case 'line': return getLineLength(el);
+ case 'polyline': return getPolylineLength(el);
+ case 'polygon': return getPolygonLength(el);
+ }
+ }
+
+ function setDashoffset(el) {
+ const pathLength = getTotalLength(el);
+ el.setAttribute('stroke-dasharray', pathLength);
+ return pathLength;
+ }
+
+ // Motion path
+
+ function getPath(path, percent) {
+ const el = is.str(path) ? selectString(path)[0] : path;
+ const p = percent || 100;
+ return function(property) {
+ return {
+ el,
+ property,
+ totalLength: getTotalLength(el) * (p / 100)
+ }
+ }
+ }
+
+ function getPathProgress(path, progress) {
+ function point(offset = 0) {
+ const l = progress + offset >= 1 ? progress + offset : 0;
+ return path.el.getPointAtLength(l);
+ }
+ const p = point();
+ const p0 = point(-1);
+ const p1 = point(+1);
+ switch (path.property) {
+ case 'x': return p.x;
+ case 'y': return p.y;
+ case 'angle': return Math.atan2(p1.y - p0.y, p1.x - p0.x) * 180 / Math.PI;
+ }
+ }
+
+ // Decompose value
+
+ function decomposeValue(val, unit) {
+ const rgx = /-?\d*\.?\d+/g;
+ const value = validateValue((is.pth(val) ? val.totalLength : val), unit) + '';
+ return {
+ original: value,
+ numbers: value.match(rgx) ? value.match(rgx).map(Number) : [0],
+ strings: (is.str(val) || unit) ? value.split(rgx) : []
+ }
+ }
+
+ // Animatables
+
+ function parseTargets(targets) {
+ const targetsArray = targets ? (flattenArray(is.arr(targets) ? targets.map(toArray) : toArray(targets))) : [];
+ return filterArray(targetsArray, (item, pos, self) => self.indexOf(item) === pos);
+ }
+
+ function getAnimatables(targets) {
+ const parsed = parseTargets(targets);
+ return parsed.map((t, i) => {
+ return {target: t, id: i, total: parsed.length, transforms: { list: getElementTransforms(t) } };
+ });
+ }
+
+ // Properties
+
+ function normalizePropertyTweens(prop, tweenSettings) {
+ let settings = cloneObject(tweenSettings);
+ if (is.arr(prop)) {
+ const l = prop.length;
+ const isFromTo = (l === 2 && !is.obj(prop[0]));
+ if (!isFromTo) {
+ // Duration divided by the number of tweens
+ if (!is.fnc(tweenSettings.duration)) settings.duration = tweenSettings.duration / l;
+ } else {
+ // Transform [from, to] values shorthand to a valid tween value
+ prop = {value: prop};
+ }
+ }
+ const propArray = is.arr(prop) ? prop : [prop];
+ return propArray.map((v, i) => {
+ // Default delay value should be applied only on the first tween
+ const delay = !i ? tweenSettings.delay : 0;
+ // Use path object as a tween value
+ let obj = is.obj(v) && !is.pth(v) ? v : {value: v};
+ // Set default delay value
+ if (is.und(obj.delay)) obj.delay = delay;
+ return obj;
+ }).map(k => mergeObjects(k, settings));
+ }
+
+ function getProperties(instanceSettings, tweenSettings, params) {
+ let properties = [];
+ const settings = mergeObjects(instanceSettings, tweenSettings);
+ for (let p in params) {
+ if (!settings.hasOwnProperty(p) && p !== 'targets') {
+ properties.push({
+ name: p,
+ offset: settings['timeOffset'],
+ tweens: normalizePropertyTweens(params[p], tweenSettings)
+ });
+ }
+ }
+ return properties;
+ }
+
+ // Tweens
+
+ function normalizeTweenValues(tween, animatable) {
+ let t = {};
+ for (let p in tween) {
+ let value = getFunctionValue(tween[p], animatable);
+ if (is.arr(value)) {
+ value = value.map(v => getFunctionValue(v, animatable));
+ if (value.length === 1) value = value[0];
+ }
+ t[p] = value;
+ }
+ t.duration = parseFloat(t.duration);
+ t.delay = parseFloat(t.delay);
+ return t;
+ }
+
+ function normalizeEasing(val) {
+ return is.arr(val) ? bezier.apply(this, val) : easings[val];
+ }
+
+ function normalizeTweens(prop, animatable) {
+ let previousTween;
+ return prop.tweens.map(t => {
+ let tween = normalizeTweenValues(t, animatable);
+ const tweenValue = tween.value;
+ const originalValue = getOriginalTargetValue(animatable.target, prop.name, animatable);
+ const previousValue = previousTween ? previousTween.to.original : originalValue;
+ const from = is.arr(tweenValue) ? tweenValue[0] : previousValue;
+ const to = getRelativeValue(is.arr(tweenValue) ? tweenValue[1] : tweenValue, from);
+ const unit = getUnit(to) || getUnit(from) || getUnit(originalValue);
+ tween.from = decomposeValue(from, unit);
+ tween.to = decomposeValue(to, unit);
+ tween.start = previousTween ? previousTween.end : prop.offset;
+ tween.end = tween.start + tween.delay + tween.duration + tween.endDelay;
+ tween.easing = normalizeEasing(tween.easing);
+ tween.elasticity = (1000 - minMaxValue(tween.elasticity, 1, 999)) / 1000;
+ tween.isPath = is.pth(tweenValue);
+ tween.isColor = is.col(tween.from.original);
+ if (tween.isColor) tween.round = 1;
+ previousTween = tween;
+ return tween;
+ });
+ }
+
+ // Tween progress
+
+ const setProgressValue = {
+ css: (t, p, v) => t.style[p] = v,
+ attribute: (t, p, v) => t.setAttribute(p, v),
+ object: (t, p, v) => t[p] = v,
+ transform: (t, p, v, transforms, manual) => {
+ transforms.list.set(p, v);
+ if (p === transforms.last || manual) {
+ let str = '';
+ for (let [prop, value] of transforms.list) {
+ str += `${prop}(${value}) `;
+ }
+ t.style.transform = str;
+ }
+ }
+ }
+
+ function setTargetValue(targets, properties) {
+ const animatables = getAnimatables(targets);
+ animatables.forEach(animatable => {
+ for (var property in properties) {
+ const value = properties[property];
+ const originalValue = getOriginalTargetValue(animatable.target, property, animatable);
+ const unit = getUnit(value) || getUnit(originalValue);
+ const to = getRelativeValue(validateValue(value, unit), originalValue);
+ const animType = getAnimationType(animatable.target, property);
+ setProgressValue[animType](animatable.target, property, to, animatable.transforms, true);
+ }
+ });
+ }
+
+ // Animations
+
+ function createAnimation(animatable, prop) {
+ const animType = getAnimationType(animatable.target, prop.name);
+ if (animType) {
+ const tweens = normalizeTweens(prop, animatable);
+ return {
+ type: animType,
+ property: prop.name,
+ animatable: animatable,
+ tweens: tweens,
+ duration: tweens[tweens.length - 1].end,
+ delay: tweens[0].delay
+ }
+ }
+ }
+
+ function getAnimations(animatables, properties) {
+ return filterArray(flattenArray(animatables.map(animatable => {
+ return properties.map(prop => {
+ return createAnimation(animatable, prop);
+ });
+ })), a => !is.und(a));
+ }
+
+ // Create Instance
+
+ function getInstanceTimings(type, animations, instanceSettings, tweenSettings) {
+ const isDelay = (type === 'delay');
+ if (animations.length) {
+ return (isDelay ? Math.min : Math.max).apply(Math, animations.map(anim => anim[type]));
+ } else {
+ return isDelay ? tweenSettings.delay : instanceSettings.timeOffset + tweenSettings.delay + tweenSettings.duration;
+ }
+ }
+
+ function createNewInstance(params) {
+ const instanceSettings = replaceObjectProps(defaultInstanceSettings, params);
+ const tweenSettings = replaceObjectProps(defaultTweenSettings, params);
+ const animatables = getAnimatables(params.targets);
+ const properties = getProperties(instanceSettings, tweenSettings, params);
+ const animations = getAnimations(animatables, properties);
+ return mergeObjects(instanceSettings, {
+ children: [],
+ animatables: animatables,
+ animations: animations,
+ duration: getInstanceTimings('duration', animations, instanceSettings, tweenSettings),
+ delay: getInstanceTimings('delay', animations, instanceSettings, tweenSettings)
+ });
+ }
+
+ // Core
+
+ let activeInstances = [];
+ let raf;
+
+ const engine = (() => {
+ function play() {
+ raf = requestAnimationFrame(step);
+ };
+ function step(t) {
+ if (activeInstances.length) {
+ let i = 0;
+ while (i < activeInstances.length) {
+ const activeInstance = activeInstances[i];
+ if (!activeInstance.paused) {
+ activeInstance.tick(t);
+ } else {
+ const instanceIndex = activeInstances.indexOf(activeInstance);
+ if (instanceIndex > -1) activeInstances.splice(instanceIndex, 1);
+ }
+ i++;
+ }
+ play();
+ } else {
+ raf = cancelAnimationFrame(raf);
+ }
+ }
+ return play;
+ })();
+
+
+ // Public Instance
+
+ function anime(params = {}) {
+
+ let now, startTime, lastTime = 0;
+
+ let resolve = null;
+
+ function makePromise() {
+ return window.Promise && new Promise(_resolve => resolve = _resolve);
+ }
+
+ let promise = makePromise();
+
+ let instance = createNewInstance(params);
+
+ function toggleInstanceDirection() {
+ instance.reversed = !instance.reversed;
+ const children = instance.children;
+ children.forEach(child => child.reversed = instance.reversed);
+ }
+
+ function adjustTime(time) {
+ return instance.reversed ? instance.duration - time : time;
+ }
+
+ function syncInstanceChildren(time, manual) {
+ const children = instance.children;
+ const childrenLength = children.length;
+ if (!manual || time >= instance.currentTime) {
+ for (let i = 0; i < childrenLength; i++) children[i].seek(time);
+ } else {
+ // Manual backward seeking requires looping in reverse
+ for (let i = childrenLength; i--;) children[i].seek(time);
+ }
+ }
+
+ function setAnimationsProgress(insTime) {
+ let i = 0;
+ const animations = instance.animations;
+ const animationsLength = animations.length;
+ while (i < animationsLength) {
+ const anim = animations[i];
+ const animatable = anim.animatable;
+ const tweens = anim.tweens;
+ const tweenLength = tweens.length - 1;
+ let tween = tweens[tweenLength];
+ // Only check for keyframes if there is more than one tween
+ if (tweenLength) tween = filterArray(tweens, t => (insTime < t.end))[0] || tween;
+ const elapsed = minMaxValue(insTime - tween.start - tween.delay, 0, tween.duration) / tween.duration;
+ const eased = isNaN(elapsed) ? 1 : tween.easing(elapsed, tween.elasticity);
+ const strings = tween.to.strings;
+ const round = tween.round;
+ const numbers = [];
+ let progress;
+ const toNumbersLength = tween.to.numbers.length;
+ for (let n = 0; n < toNumbersLength; n++) {
+ let value;
+ const toNumber = tween.to.numbers[n];
+ const fromNumber = tween.from.numbers[n];
+ if (!tween.isPath) {
+ value = fromNumber + (eased * (toNumber - fromNumber));
+ } else {
+ value = getPathProgress(tween.value, eased * toNumber);
+ }
+ if (round) {
+ if (!(tween.isColor && n > 2)) {
+ value = Math.round(value * round) / round;
+ }
+ }
+ numbers.push(value);
+ }
+ // Manual Array.reduce for better performances
+ const stringsLength = strings.length;
+ if (!stringsLength) {
+ progress = numbers[0];
+ } else {
+ progress = strings[0];
+ for (let s = 0; s < stringsLength; s++) {
+ const a = strings[s];
+ const b = strings[s + 1];
+ const n = numbers[s];
+ if (!isNaN(n)) {
+ if (!b) {
+ progress += n + ' ';
+ } else {
+ progress += n + b;
+ }
+ }
+ }
+ }
+ setProgressValue[anim.type](animatable.target, anim.property, progress, animatable.transforms);
+ anim.currentValue = progress;
+ i++;
+ }
+ instance.currentTime = insTime;
+ instance.progress = (insTime / instance.duration) * 100;
+ }
+
+ function setCallback(cb) {
+ if (instance[cb]) instance[cb](instance);
+ }
+
+ function countIteration() {
+ if (instance.remaining && instance.remaining !== true) {
+ instance.remaining--;
+ }
+ }
+
+ function setInstanceProgress(engineTime, manual) {
+ const insOffset = instance.timeOffset;
+ const insDuration = instance.duration;
+ const insTime = adjustTime(engineTime);
+ if (instance.children.length) syncInstanceChildren(insTime, manual);
+ if (insTime >= (insOffset + instance.delay) || !insDuration) {
+ if (!instance.began) {
+ instance.began = true;
+ setCallback('begin');
+ }
+ setCallback('run');
+ }
+ if (insTime > insOffset && insTime < insDuration) {
+ setAnimationsProgress(insTime);
+ } else {
+ if (insTime <= insOffset && instance.currentTime !== 0) {
+ setAnimationsProgress(0);
+ if (instance.reversed) countIteration();
+ }
+ if ((insTime >= insDuration && instance.currentTime !== insDuration) || !insDuration) {
+ setAnimationsProgress(insDuration);
+ if (!instance.reversed) countIteration();
+ }
+ }
+ setCallback('update');
+ if (engineTime >= insDuration) {
+ if (instance.remaining) {
+ startTime = now;
+ if (instance.direction === 'alternate') toggleInstanceDirection();
+ } else {
+ instance.paused = true;
+ if (!instance.completed) {
+ instance.completed = true;
+ setCallback('complete');
+ if ('Promise' in window) {
+ resolve();
+ promise = makePromise();
+ }
+ }
+ }
+ lastTime = 0;
+ }
+ }
+
+ instance.reset = function() {
+ const direction = instance.direction;
+ const loops = instance.loop;
+ instance.currentTime = 0;
+ instance.progress = 0;
+ instance.paused = true;
+ instance.began = false;
+ instance.completed = false;
+ instance.reversed = direction === 'reverse';
+ instance.remaining = direction === 'alternate' && loops === 1 ? 2 : loops;
+ setAnimationsProgress(0);
+ for (let i = instance.children.length; i--; ){
+ instance.children[i].reset();
+ }
+ }
+
+ instance.tick = function(t) {
+ now = t;
+ if (!startTime) startTime = now;
+ const engineTime = (lastTime + now - startTime) * anime.speed;
+ setInstanceProgress(engineTime);
+ }
+
+ instance.seek = function(time) {
+ setInstanceProgress(adjustTime(time), true);
+ }
+
+ instance.pause = function() {
+ instance.paused = true;
+ }
+
+ instance.play = function() {
+ if (!instance.paused) return;
+ instance.paused = false;
+ startTime = 0;
+ lastTime = adjustTime(instance.currentTime);
+ activeInstances.push(instance);
+ if (!raf) engine();
+ }
+
+ instance.reverse = function() {
+ toggleInstanceDirection();
+ startTime = 0;
+ lastTime = adjustTime(instance.currentTime);
+ }
+
+ instance.restart = function() {
+ instance.pause();
+ instance.reset();
+ instance.play();
+ }
+
+ instance.finished = promise;
+
+ instance.reset();
+
+ if (instance.autoplay) instance.play();
+
+ return instance;
+
+ }
+
+ // Remove targets from animation
+
+ function removeTargets(targets) {
+ const targetsArray = parseTargets(targets);
+ for (let i = activeInstances.length; i--;) {
+ const instance = activeInstances[i];
+ const animations = instance.animations;
+ for (let a = animations.length; a--;) {
+ if (arrayContains(targetsArray, animations[a].animatable.target)) {
+ animations.splice(a, 1);
+ if (!animations.length) instance.pause();
+ }
+ }
+ }
+ }
+
+ // Timeline
+
+ function timeline(params = {}) {
+ let tl = anime(params);
+ tl.pause();
+ tl.duration = 0;
+ tl.add = function(instanceParams, timeOffset) {
+ tl.children.forEach(i => { i.began = true; i.completed = true; });
+ let insParams = mergeObjects(instanceParams, replaceObjectProps(defaultTweenSettings, params));
+ insParams.targets = insParams.targets || params.targets;
+ const tlDuration = tl.duration;
+ insParams.autoplay = false;
+ insParams.direction = tl.direction;
+ insParams.timeOffset = is.und(timeOffset) ? tlDuration : getRelativeValue(timeOffset, tlDuration);
+ tl.began = true;
+ tl.completed = true;
+ tl.seek(insParams.timeOffset);
+ const ins = anime(insParams);
+ ins.began = true;
+ ins.completed = true;
+ if (ins.duration > tlDuration) tl.duration = ins.duration;
+ tl.children.push(ins);
+ tl.seek(0);
+ tl.reset();
+ if (tl.autoplay) tl.restart();
+ return tl;
+ }
+ return tl;
+ }
+
+ anime.version = '3.0.0-alpha';
+ anime.speed = 1;
+ anime.running = activeInstances;
+ anime.remove = removeTargets;
+ anime.get = getOriginalTargetValue;
+ anime.set = setTargetValue;
+ anime.path = getPath;
+ anime.setDashoffset = setDashoffset;
+ anime.bezier = bezier;
+ anime.easings = easings;
+ anime.timeline = timeline;
+ anime.random = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
+
+ return anime;
+
+}));
\ No newline at end of file
diff --git a/documentation/examples/anime-DOM-stress-test-02.html b/documentation/examples/anime-DOM-stress-test-02.html
index 3f6d221f..0090865f 100644
--- a/documentation/examples/anime-DOM-stress-test-02.html
+++ b/documentation/examples/anime-DOM-stress-test-02.html
@@ -71,10 +71,10 @@
translateX: [0, Math.sin(angle) * randomDistance],
translateY: [0,Math.cos(angle) * randomDistance],
scale: [
- {value: [0, anime.random(5, 10) * .1], easing: 'out-back'},
- {value: 0, easing: 'in-back'},
+ {value: [0, anime.random(5, 10) * .1], easing: 'easeOutBack'},
+ {value: 0, easing: 'easeInBack'},
],
- easing: 'in-out-sine',
+ easing: 'easeInOutSine',
direction: 'reverse',
duration: duration
});
diff --git a/documentation/examples/anime-DOM-stress-test.html b/documentation/examples/anime-DOM-stress-test.html
index 5a1fb164..04351595 100644
--- a/documentation/examples/anime-DOM-stress-test.html
+++ b/documentation/examples/anime-DOM-stress-test.html
@@ -100,7 +100,7 @@
return anime.random(0, duration);
},
loop: true,
- easing: 'in-out-sine',
+ easing: 'easeInOutSine',
duration: duration
});
wrapperEl.appendChild(el);
diff --git a/documentation/examples/anime-speed-test.html b/documentation/examples/anime-speed-test.html
index 84c037d8..77534ffb 100644
--- a/documentation/examples/anime-speed-test.html
+++ b/documentation/examples/anime-speed-test.html
@@ -17,6 +17,7 @@
<link rel="icon" type="image/png" href="../assets/img/icons/favicon.png">
<link href="../assets/css/anime.css" rel="stylesheet">
<script src="../../anime.js"></script>
+ <!-- <script src="../assets/js/anime.3.0.0-alpha.js"></script> -->
<!-- <script src="../assets/js/anime.2.2.0.js"></script> -->
<!-- <script src="../assets/js/anime.2.0.1.js"></script> -->
<!-- <script src="../assets/js/anime.1.3.js"></script> -->
@@ -26,61 +27,57 @@
position: absolute;
width: 100%;
height: 100%;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ font-size: 20px;
}
.wrapper {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
+ display: flex;
+ flex-wrap: wrap;
+ width: 30em;
+ height: 30em;
}
.particule {
- position: absolute;
- top: 50%;
- left: 50%;
- border-radius: 50%;
+ width: 1em;
+ height: 1em;
}
</style>
</head>
<body>
+ <div class="wrapper"></div>
<script>
- var numberOfEls = 1000;
- var duration = 1500;
+ var numberOfEls = 900;
+ var duration = 1000;
+ var stagger = duration / numberOfEls;
var midScreenX = window.innerWidth / 2;
var midScreenY = window.innerHeight / 2;
var radius = Math.sqrt(midScreenX * midScreenX + midScreenY * midScreenY);
var fragment = document.createDocumentFragment();
+ var wrapperEl = document.querySelector('.wrapper');
for (var i = 0; i < numberOfEls; i++) {
- var hue = 180 + Math.round(90 / numberOfEls * i);
- var angle = anime.random(-360, 360);
+ var hue = 0 + Math.round(40 / numberOfEls * i);
var el = document.createElement('div');
el.classList.add('particule');
el.style.backgroundColor = 'hsl(' + hue + ', 100%, 40%)';
- el.style.width = '25px';
- el.style.height = '25px';
+
anime({
targets: el,
- rotate: [angle, angle],
- translateX: window.innerWidth * .65,
- // rotate: [anime.random(-360, 360), anime.random(-360, 360)],
- scale: {
- value: [0, 1],
- duration: 100,
- endDelay: duration
- },
- delay: (duration / numberOfEls) * i,
- endDelay: (duration / numberOfEls) * i,
- duration: duration,
- easing: 'in-expo',
- direction: 'reverse',
- loop: true
+ translateX: '1em',
+ translateY: '1em',
+ scale: .5,
+ rotate: 90,
+ direction: 'alternate',
+ loop: true,
+ easing: 'easeInOutSine',
+ timeOffset: i * stagger
});
fragment.appendChild(el);
}
- document.body.appendChild(fragment);
+ wrapperEl.appendChild(fragment);
</script>
<script src="../assets/js/stats.js"></script>