JavaScript animation engine
Add built-in stagger helper
Julian Garnier7b445c752120
diff --git a/documentation/examples/anime-complex-properties.html b/documentation/examples/anime-complex-properties.htmlindex 3a4d3902..966acfdf 100644--- a/documentation/examples/anime-complex-properties.html+++ b/documentation/examples/anime-complex-properties.html@@ -16,7 +16,7 @@<link rel="apple-touch-icon-precomposed" href="../assets/img/icons/apple-touch-icon.png"><link rel="icon" type="image/png" href="../assets/img/icons/favicon.png"><link href="../assets/css/documentation.css" rel="stylesheet">- <script src="../../lib/anime.min.js"></script>+ <!-- <script src="../../lib/anime.min.js"></script> --><!-- <script src="../assets/js/anime/anime.1.3.js"></script> --><!-- <script src="../assets/js/anime/anime.2.0.1.js"></script> --><style>@@ -59,85 +59,99 @@</g></g></svg>+ <input class="item" type="range" value="0"><script type="module">- // import anime from "../../src/index.js";+ import anime from "../../src/index.js";- var boxShadow = anime({- targets: '.box-shadow',- boxShadow: [- {value: ['10px -10px 10px 0 currentColor', '10px 10px 20px 0 currentColor']},- {value: '-10px 10px 30px 0 currentColor'},- {value: '-10px -10px 20px 0 currentColor'},- {value: '10px -10px 10px 0 currentColor'}- ],- loop: true,- easing: 'linear'- });- var unitLess = anime({- targets: '.unit-less',- borderRadius: 10,- loop: true,- direction: 'alternate',- easing: 'linear'- });- var specifiedUnit = anime({- targets: '.specified-unit',- borderRadius: ['0px', '50px'],- loop: true,- direction: 'alternate',- easing: 'linear'- });- var filter = anime({- targets: '.filter',- filter: ["blur(20px)", "blur(0px)"],- loop: true,- direction: 'alternate',- easing: 'linear'- });- var rgba = anime({- targets: '.rgba',- backgroundColor: ['rgba(255,100,50,1)', 'rgba(255,100,50,.0)'],- loop: true,- direction: 'alternate',- easing: 'linear'- });- var calc = anime({- targets: '.calc',- height: ['calc(25% - 100px)', 'calc(25% - 0px)'],- loop: true,- direction: 'alternate',- easing: 'linear'- });- var zeroValue = anime({- targets: '.zero-value',- scale: 0,- loop: true,- direction: 'alternate',- easing: 'linear'- });- var roundValue = anime({- targets: '.round-value',- translateY: 100,- loop: true,- round: 1,- direction: 'alternate',- easing: 'linear'- });- var clipPath = anime({- targets: '.clip-path',- clipPath: ['circle(0px at center)', 'circle(100px at center)'],- loop: true,- direction: 'alternate',- easing: 'linear'- });- var svgTransform = anime({- targets: 'rect',- transform: 'translate(10 10) scale(2)',- loop: true,- direction: 'alternate',- easing: 'linear'- });+ // var boxShadow = anime({+ // targets: '.box-shadow',+ // boxShadow: [+ // {value: ['10px -10px 10px 0 currentColor', '10px 10px 20px 0 currentColor']},+ // {value: '-10px 10px 30px 0 currentColor'},+ // {value: '-10px -10px 20px 0 currentColor'},+ // {value: '10px -10px 10px 0 currentColor'}+ // ],+ // loop: true,+ // easing: 'linear'+ // });+ // var unitLess = anime({+ // targets: '.unit-less',+ // borderRadius: 10,+ // loop: true,+ // direction: 'alternate',+ // easing: 'linear'+ // });+ // var specifiedUnit = anime({+ // targets: '.specified-unit',+ // borderRadius: ['0px', '50px'],+ // loop: true,+ // direction: 'alternate',+ // easing: 'linear'+ // });+ // var filter = anime({+ // targets: '.filter',+ // filter: ["blur(20px)", "blur(0px)"],+ // loop: true,+ // direction: 'alternate',+ // easing: 'linear'+ // });+ // var rgba = anime({+ // targets: '.rgba',+ // backgroundColor: ['rgba(255,100,50,1)', 'rgba(255,100,50,.0)'],+ // loop: true,+ // direction: 'alternate',+ // easing: 'linear'+ // });+ // var calc = anime({+ // targets: '.calc',+ // height: ['calc(25% - 100px)', 'calc(25% - 0px)'],+ // loop: true,+ // direction: 'alternate',+ // easing: 'linear'+ // });+ // var zeroValue = anime({+ // targets: '.zero-value',+ // scale: 0,+ // loop: true,+ // direction: 'alternate',+ // easing: 'linear'+ // });+ // var roundValue = anime({+ // targets: '.round-value',+ // translateY: 100,+ // loop: true,+ // round: 1,+ // direction: 'alternate',+ // easing: 'linear'+ // });+ // var clipPath = anime({+ // targets: '.clip-path',+ // clipPath: ['circle(0px at center)', 'circle(100px at center)'],+ // loop: true,+ // direction: 'alternate',+ // easing: 'linear'+ // });+ // var svgTransform = anime({+ // targets: 'rect',+ // transform: 'translate(10 10) scale(2)',+ // loop: true,+ // direction: 'alternate',+ // easing: 'linear'+ // });+ window.onload = function() {+ var inputEl = document.querySelector('input');+ var rangeValue = anime({+ targets: inputEl,+ value: 100,+ //round: 1,+ loop: true,+ direction: 'alternate',+ easing: 'linear'+ });+ // anime.setValue(input, {'value': 50});+ //inputEl.setAttribute('value', 75);+ }</script></body></html>diff --git a/documentation/examples/anime-easings.html b/documentation/examples/anime-easings.htmlnew file mode 100644index 00000000..bbf3b8da--- /dev/null+++ b/documentation/examples/anime-easings.html@@ -0,0 +1,147 @@+<!DOCTYPE html>+<html>+<head>+ <title>stagger | anime.js</title>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">+ <meta property="og:title" content="anime.js">+ <meta property="og:url" content="http://animejs.com">+ <meta property="og:description" content="Javascript Animation Engine">+ <meta property="og:image" content="http://animejs.com/documentation/assets/img/icons/og.png">+ <meta name="twitter:card" content="summary">+ <meta name="twitter:title" content="anime.js">+ <meta name="twitter:site" content="@juliangarnier">+ <meta name="twitter:description" content="Javascript Animation Engine">+ <meta name="twitter:image" content="http://animejs.com/documentation/assets/img/icons/twitter.png">+ <link rel="apple-touch-icon-precomposed" href="../assets/img/icons/apple-touch-icon.png">+ <link rel="icon" type="image/png" href="../assets/img/icons/favicon.png" >+ <link href="../assets/css/documentation.css" rel="stylesheet">+ <style>++ body {+ display: flex;+ flex-wrap: wrap;+ justify-content: center;+ align-items: center;+ }++ .easing-visualizer {+ display: flex;+ justify-content: space-between;+ align-items: flex-end;+ width: 400px;+ height: 400px;+ }++ .easing-visualizer div {+ width: 8px;+ height: 8px;+ margin: 0 0 0 0;+ background-color: #FFF;+ transform-origin: 50% 100%;+ border-radius: 50%;+ }++ </style>+</head>+<body>++ <div class="easing-visualizer"></div>++</body>+<script type="module">++ import anime from '../../src/index.js';++ 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))+ }++ 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 stagger(val, params = {}) {+ const direction = params.direction || 'normal';+ const grid = params.grid;+ const isRange = is.arr(val);+ const val1 = isRange ? parseFloat(val[0]) : parseFloat(val);+ const val2 = isRange ? parseFloat(val[1]) : 0;+ const start = params.start || 0 + (isRange ? val1 : 0);+ const easing = params.easing ? anime.easing(params.easing) : null;+ const unit = getUnit(isRange ? val[1] : val) || 0;+ const values = [];+ let maxValue = 0;+ let from = params.from || 0;+ let intialValue = from;+ return (el, i, t) => {+ if (from === 'middle') intialValue = (t - 1) / 2;+ if (from === 'last') intialValue = t - 1;+ if (!values.length) {+ for (let index = 0; index < t; index++) {+ if (grid) {+ // const x = from !== 'middle' ? intialValue%grid[0] : (grid[0]/2)%grid[0];+ // const y = from !== 'middle' ? Math.ceil(intialValue/grid[1]) : Math.ceil((grid[1]/2)/grid[1]);+ const x = grid[0] / 2;+ const y = grid[1] / 2;+ const dx = x - (index%grid[0]);+ const dy = y - (Math.ceil(index/grid[1]));+ //console.log(dx, dy);+ values.push(Math.sqrt(dx * dx + dy * dy));+ } else {+ values.push(Math.abs(intialValue - index));+ }+ maxValue = Math.max(...values);+ }+ }+ let progress = values[i];+ if (easing) progress = easing(progress / maxValue) * maxValue;+ if (direction === 'reverse') progress = Math.abs(maxValue - progress);+ const spacing = isRange ? (val2 - val1) / maxValue : val1;+ return start + (spacing * progress) + unit;+ }+ }++ const easingVisualizerEl = document.querySelector('.easing-visualizer');+ const fragment = document.createDocumentFragment();+ const numberOfElements = 51;++ for (let i = 0; i < numberOfElements; i++) {+ fragment.appendChild(document.createElement('div'));+ }++ easingVisualizerEl.appendChild(fragment);++ anime({+ targets: '.easing-visualizer div',+ translateY: (() => {+ const keyframes = [];+ for (let ease in anime.penner) {+ keyframes.push({+ value: stagger([0, -400], {easing: ease}),+ delay: stagger(.125)+ });+ };+ keyframes.push({ value: stagger([0, -400], {easing: 'steps(10)'}), delay: stagger(.125) });+ keyframes.push({ value: 0, delay: stagger(.125) });+ return keyframes;+ })(),+ easing: 'easeInOutSine',+ duration: 16000,+ loop: true+ });++</script>+</html>diff --git a/documentation/examples/anime-stager.html b/documentation/examples/anime-stager.htmlindex accab843..cd3ad2ce 100644--- a/documentation/examples/anime-stager.html+++ b/documentation/examples/anime-stager.html@@ -343,10 +343,11 @@var animation = anime({targets: '.el',- rotate: stager.splash(window.innerWidth / 2, window.innerHeight / 2, 10),- scaleX: stager.centerIn(.01),- direction: 'alternate',+ rotate: stager.splash(window.innerWidth / 2, window.innerHeight / 2, 90),+ scaleX: .05,delay: stager.splash(window.innerWidth / 2, window.innerHeight / 2, 100),+ easing: 'easeInOutQuart',+ direction: 'alternate',loop: true});diff --git a/documentation/examples/anime-stagger-2.html b/documentation/examples/anime-stagger-2.htmlnew file mode 100644index 00000000..325720c1--- /dev/null+++ b/documentation/examples/anime-stagger-2.html@@ -0,0 +1,299 @@+<!DOCTYPE html>+<html>+<head>+ <title>stagger | anime.js</title>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">+ <meta property="og:title" content="anime.js">+ <meta property="og:url" content="http://animejs.com">+ <meta property="og:description" content="Javascript Animation Engine">+ <meta property="og:image" content="http://animejs.com/documentation/assets/img/icons/og.png">+ <meta name="twitter:card" content="summary">+ <meta name="twitter:title" content="anime.js">+ <meta name="twitter:site" content="@juliangarnier">+ <meta name="twitter:description" content="Javascript Animation Engine">+ <meta name="twitter:image" content="http://animejs.com/documentation/assets/img/icons/twitter.png">+ <link rel="apple-touch-icon-precomposed" href="../assets/img/icons/apple-touch-icon.png">+ <link rel="icon" type="image/png" href="../assets/img/icons/favicon.png" >+ <link href="../assets/css/documentation.css" rel="stylesheet">+ <style>++ body {+ display: flex;+ flex-wrap: wrap;+ justify-content: center;+ align-items: center;+ position: absolute;+ width: 100%;+ height: 100%;+ background-color: #000;+ }++ .testarea {+ position: fixed;+ z-index: 1;+ display: flex;+ flex-wrap: wrap;+ justify-content: center;+ align-items: center;+ flex-shrink: 0;+ width: calc( 20 * 2rem);+ height: calc( 20 * 2rem);+ perspective: 100px;+ }++ .el {+ width: 2rem;+ height: 2rem;+ /*background-color: currentColor;*/+ background-color: #000;+ border: 2px solid currentColor;+ }++ /* Player animation */++ .timeline {+ opacity: .2;+ position: absolute;+ flex-shrink: 0;+ width: 100%;+ height: 100%;+ padding-top: 4px;+ }++ .timeline.player-animation {+ width: 100%;+ left: 0;+ }++ .tl-needle {+ position: fixed;+ z-index: 2;+ top: 0;+ left: 0;+ width: 2px;+ height: 100%;+ margin-left: -1px;+ background-color: #FFF;+ }++ .tl-animation {+ position: relative;+ display: flex;+ justify-content: space-between;+ width: auto;+ height: 8px;+ margin-bottom: 4px;+ background-color: currentColor;+ border-radius: .5rem;+ }++ .tl-delay,+ .tl-end-delay {+ width: auto;+ height: 100%;+ background-color: rgba(0,0,0,.5);+ }++ </style>+</head>+<body>++ <div class="testarea"></div>++ <div class="log log-animation"></div>+ <div class="time time-animation"></div>++</body>+<script type="module">++ import anime from '../../src/index.js';++ var animationTimeLogEl = document.querySelector('.time-animation');+ var timelineTimeLogEl = document.querySelector('.time-timeline');++ var testAreaEl = document.querySelector('.testarea');+ var fragment = document.createDocumentFragment();+ var colorIndex = 1;++ for (var i = 0; i < 400; i++) {+ var el = document.createElement('div');+ el.classList.add('el');+ el.classList.add('color-'+('0' + colorIndex).slice(-2));+ colorIndex++;+ if (colorIndex > 12) colorIndex = 1;+ fragment.appendChild(el);+ }++ testAreaEl.appendChild(fragment);++ var stagger = {+ leftToRight: (spacing, min, max) => {+ return (el, i, t) => {+ let delay = i * spacing;+ if (min) delay += min;+ if (max) delay = i * ((max - min) / t);+ return delay;+ }+ },+ rightToLeft: spacing => {+ return (el, i, t) => {+ return ((t - 1) - i) * spacing;+ }+ },+ centerOut: spacing => {+ return (el, i, t) => {+ return Math.abs(Math.round((t / 2) - i - 1)) * spacing+ }+ },+ centerIn: spacing => {+ return (el, i, t) => {+ return (i >= t / 2 ? ((t - 1) - i) : i) * spacing+ }+ },+ splash: (x, y, spacing) => {+ return (el, i) => {+ const rect = el.getBoundingClientRect();+ const dx = x - (rect.left + (rect.width / 2));+ const dy = y - (rect.top + (rect.height / 2));+ const distance = Math.sqrt( dx * dx + dy * dy );+ return (distance / 100) * spacing;+ }+ }+ }++ // anime.stagger(0, 1, 100);+ // anime.stagger(1, 0, 100);+ // anime.stagger(.5, 1, 100);+ // anime.stagger(1, .5, 100);+ // anime.stagger({x: window.innerWidth / 2, y: window.innerWidth / 2}, 1, 100);+ // anime.stagger('-2rem', '2rem');++ // anime.stagger.linear(100, true);+ // anime.stagger.splash();++ // anime.stagger.from.first([0, 200]);+ // anime.stagger.from.last([0, 200]);+ // anime.stagger.from.middle(100);+ // anime.stagger.from.index(3, 100);+ // anime.stagger.from.point({x: 2, y: 5}, 100);++ // anime.stagger.to.first(100);+ // anime.stagger.to.last(100);+ // anime.stagger.to.middle(100);+ // anime.stagger.to.index(3, 100);+ // anime.stagger.to.point({x: 2, y: 5}, 100);++ // anime.cycle.from.first([0, 200, 400]);+ // anime.cycle.from.last([0, 200, 400]);+ // anime.cycle.from.middle([-100, 100]);+ // anime.cycle.from.index(3, [-2, 2]);+ // anime.cycle.from.point({x: 2, y: 5}, 100);++ // anime.cycle.to.first([0, 200, 400]);+ // anime.cycle.to.last([0, 200, 400]);+ // anime.cycle.to.middle([-100, 100]);+ // anime.cycle.to.index(3, [-2, 2]);+ // anime.cycle.to.point({x: 2, y: 5}, 100);+++ var animation = anime({+ targets: '.el',+ //translateX: function() {return anime.random(-100, 100)},+ translateY: function() {return anime.random(-100, 100)},+ rotate: function() {return anime.random(-360, 360)},+ //scale: function() {return anime.random(50, 200) / 100},+ // backgroundColor: {value: 'rgba(0,0,0,1)', easing: 'easeOutQuad'},+ // border: {value: '1px solid currentColor', easing: 'easeOutQuad'},+ delay: stagger.splash(window.innerWidth / 2, window.innerHeight / 2, 200),+ easing: 'easeOutQuad',+ direction: 'alternate',+ loop: true+ });++ // var animation = anime({+ // targets: '.el',+ // //translateZ: 40,+ // scale: function(el, i, t) { var func = stagger.splash(window.innerWidth / 2, window.innerHeight / 2, 1.1); return 1.1 - func(el, i, t); },+ // rotate: function(el, i, t) { var func = stagger.splash(window.innerWidth / 2, window.innerHeight / 2, 20); return 20 - func(el, i, t); },+ // delay: stagger.splash(window.innerWidth / 2, window.innerHeight / 2, 500),+ // easing: 'easeInOutCirc',+ // duration: 2000,+ // direction: 'alternate',+ // loop: true+ // });++ function animePlayer(instance, playerClass) {++ function createEl(type, className, parentEl) {+ var el = document.createElement(type);+ if (className) el.classList.add(className);+ if (parentEl) parentEl.appendChild(el);+ return el;+ }++ var timelineEl = createEl('div', 'timeline', document.body);+ if (playerClass) timelineEl.classList.add(playerClass);+ var needleEl = createEl('div', 'tl-needle', timelineEl);+ var animations = [];+ var colors = ['#FF1461','#FF7C72','#FBF38C','#A6FF8F','#18FF92','#1CE2B2','#5EF3FB','#61C3FF','#5A87FF','#8453E3','#C26EFF','#FB89FB'];+ var colorIndex = 0;++ function convertMStoEM(ms) { return ms / 100; }+ function convertEMtoMS(em) { return parseFloat(em) * 250; }++ function createAnimationLog(animObj, timelineOffset) {+ var anim = animObj;+ anim.player = {};+ anim.player.animationEl = createEl('div', 'tl-animation', timelineEl);+ anim.player.delayEl = createEl('div', 'tl-delay', anim.player.animationEl);+ anim.player.endDelayEl = createEl('div', 'tl-end-delay', anim.player.animationEl);+ anim.update = function() {+ anime.setValue(anim.player.animationEl, {+ left: convertMStoEM(timelineOffset) + 'em',+ width: convertMStoEM(anim.duration) + 'em'+ });+ anime.setValue(anim.player.delayEl, {width: (anim.delay / anim.duration) * 100 + '%'});+ anime.setValue(anim.player.endDelayEl, {width: (anim.endDelay / anim.duration) * 100 + '%'});+ }+ anime.setValue(anim.player.animationEl, {color: colors[colorIndex]});+ colorIndex++;+ if (!colors[colorIndex]) colorIndex = 0;+ anim.update();+ animations.push(anim);+ return anim;+ }++ instance.pause();++ var playerAnimation = anime({+ targets: needleEl,+ translateX: convertMStoEM(instance.duration) + 'em',+ duration: instance.duration,+ direction: instance.direction,+ loop: instance.loop,+ easing: 'linear',+ update: function(a) {+ instance.seek(a.currentTime);+ }+ });++ if (instance.children.length) {+ instance.children.forEach(function(child) {+ console.log(child.timelineOffset);+ child.animations.forEach(function(anim) {+ createAnimationLog(anim, child.timelineOffset);+ });+ })+ } else {+ instance.animations.forEach(function(anim) {+ createAnimationLog(anim);+ });+ }++ }++ //animePlayer(animation, 'player-animation');++</script>+</html>diff --git a/documentation/examples/anime-stagger-3.html b/documentation/examples/anime-stagger-3.htmlnew file mode 100644index 00000000..2402fd9b--- /dev/null+++ b/documentation/examples/anime-stagger-3.html@@ -0,0 +1,431 @@+<!DOCTYPE html>+<html>+<head>+ <title>stagger | anime.js</title>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">+ <meta property="og:title" content="anime.js">+ <meta property="og:url" content="http://animejs.com">+ <meta property="og:description" content="Javascript Animation Engine">+ <meta property="og:image" content="http://animejs.com/documentation/assets/img/icons/og.png">+ <meta name="twitter:card" content="summary">+ <meta name="twitter:title" content="anime.js">+ <meta name="twitter:site" content="@juliangarnier">+ <meta name="twitter:description" content="Javascript Animation Engine">+ <meta name="twitter:image" content="http://animejs.com/documentation/assets/img/icons/twitter.png">+ <link rel="apple-touch-icon-precomposed" href="../assets/img/icons/apple-touch-icon.png">+ <link rel="icon" type="image/png" href="../assets/img/icons/favicon.png" >+ <link href="../assets/css/documentation.css" rel="stylesheet">+ <style>++ body {+ display: flex;+ flex-wrap: wrap;+ justify-content: center;+ align-items: center;+ }++ .testarea {+ display: flex;+ flex-direction: row;+ align-items: center;+ flex-wrap: wrap;+ flex-shrink: 0;+ width: 100%;+ height: 100%;+ }++ .demo {+ position: relative;+ width: auto;+ height: 4rem;+ padding: 2rem;+ }++ .demo-title {+ position: absolute;+ top: 0;+ left: 2rem;+ }++ .demo div {+ width: 2rem;+ height: 2rem;+ /*background-color: currentColor;*/+ border: 2px solid currentColor;+ }++ /* Player animation */++ .timeline {+ opacity: .2;+ position: fixed;+ flex-shrink: 0;+ width: 100%;+ height: 100%;+ padding-top: 4px;+ }++ .timeline.player-animation {+ width: 100%;+ left: 0;+ }++ .tl-needle {+ position: fixed;+ z-index: 2;+ top: 0;+ left: 0;+ width: 2px;+ height: 100%;+ margin-left: -1px;+ background-color: #FFF;+ }++ .tl-animation {+ position: relative;+ display: flex;+ justify-content: space-between;+ width: auto;+ height: 8px;+ margin-bottom: 4px;+ background-color: currentColor;+ border-radius: .5rem;+ }++ .tl-delay,+ .tl-end-delay {+ width: auto;+ height: 100%;+ background-color: rgba(0,0,0,.5);+ }++ </style>+</head>+<body>++ <div class="player-animation"></div>++ <div class="testarea">++ <section class="demo normal">+ <h1 class="demo-title">Normal</h1>+ <div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo normal-reversed">+ <h1 class="demo-title">Normal reversed</h1>+ <div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-last">+ <h1 class="demo-title">From last</h1>+ <div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-last-reversed">+ <h1 class="demo-title">From last reversed</h1>+ <div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-middle">+ <h1 class="demo-title">From middle</h1>+ <div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-middle-reversed">+ <h1 class="demo-title">From middle reversed</h1>+ <div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-index">+ <h1 class="demo-title">From index</h1>+ <div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-index-reversed">+ <h1 class="demo-title">From index reversed</h1>+ <div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo range">+ <h1 class="demo-title">Range</h1>+ <div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo range-reversed">+ <h1 class="demo-title">Range reversed</h1>+ <div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo range-from-last">+ <h1 class="demo-title">Range from last</h1>+ <div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo range-from-last-reversed">+ <h1 class="demo-title">Range from last reversed</h1>+ <div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo range-from-middle">+ <h1 class="demo-title">Range from middle</h1>+ <div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo range-from-middle-reversed">+ <h1 class="demo-title">Range from middle reversed</h1>+ <div></div><div></div><div></div><div></div><div></div>+ </section>++ </div>++</body>+<script type="module">++ import anime from '../../src/index.js';++ // var animationTimeLogEl = document.querySelector('.time-animation');+ // var timelineTimeLogEl = document.querySelector('.time-timeline');++ // var testAreaEl = document.querySelector('.testarea');+ // var fragment = document.createDocumentFragment();+ // var colorIndex = 1;++ // for (var i = 0; i < 10; i++) {+ // var el = document.createElement('div');+ // el.classList.add('el');+ // el.classList.add('color-'+('0' + colorIndex).slice(-2));+ // colorIndex++;+ // if (colorIndex > 12) colorIndex = 1;+ // fragment.appendChild(el);+ // }++ // testAreaEl.appendChild(fragment);++ // splash: (x, y, spacing) => {+ // return (el, i) => {+ // const rect = el.getBoundingClientRect();+ // const dx = x - (rect.left + (rect.width / 2));+ // const dy = y - (rect.top + (rect.height / 2));+ // const distance = Math.sqrt( dx * dx + dy * dy );+ // return (distance / 100) * spacing;+ // }++ 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))+ }++ 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 stagger(val, params = {}) {+ const direction = params.direction || 'normal';+ const isRange = is.arr(val);+ const val1 = isRange ? parseFloat(val[0]) : parseFloat(val);+ const val2 = isRange ? parseFloat(val[1]) : 0;+ let from = params.from || 0;+ const start = params.start || 0 + (isRange ? val1 : 0);+ const unit = getUnit(isRange ? val[1] : val) || 0;+ return (el, i, t) => {+ const spacing = isRange ? (val2 - val1) / (t - 1) : val1;+ let index = i;+ if (from === 'middle') from = (t - 1) / 2;+ if (from === 'last') from = (t - 1);+ if (from && !isNaN(from)) index = from - i;+ //if (!isRange) index = Math.abs(index);+ //index = Math.abs(index);+ let progress = index;+ if (direction === 'reverse') {+ //progress = (t - 1) - index;+ //if (from === 'middle') progress = progress - ((t - 1) / 2);+ //if (from && !isNaN(from)) progress = progress ;+ progress = progress;+ console.log(progress);+ //if (from && !isNaN(from)) progress = progress - 1;+ }+ //const progress = direction === 'reverse' ? (t - 1) - index : index;+ //console.log(index, progress);+ //const progress = direction === 'reverse' ? (t - 1 - (!isNaN(from) ? from : 0)) - index : index;+ //console.log(start, spacing, progress, unit, t, index, !isNaN(from));+ return start + (spacing * progress) + unit;+ }+ }++ var animations = anime.timeline({+ easing: 'easeInOutQuad',+ //direction: 'alternate',+ loop: true+ })+ // .add({+ // targets: '.normal div',+ // translateY: stagger('-1em'),+ // delay: stagger(200)+ // }, 0)+ // .add({+ // targets: '.normal-reversed div',+ // translateY: stagger('-1em', { direction: 'reverse' }),+ // delay: stagger(200, { direction: 'reverse' }),+ // }, 0)+ // .add({+ // targets: '.from-last div',+ // translateY: stagger('-1em', {from: 'last'}),+ // delay: stagger(200, {from: 'last'})+ // }, 0)+ // .add({+ // targets: '.from-last-reversed div',+ // translateY: stagger('-1em', { from: 'last', direction: 'reverse' }),+ // delay: stagger(200, { from: 'last', direction: 'reverse' }),+ // }, 0)+ // .add({+ // targets: '.from-middle div',+ // translateY: stagger('-1em', {from: 'middle'}),+ // delay: stagger(200, {from: 'middle'})+ // }, 0)+ // .add({+ // targets: '.from-middle-reversed div',+ // translateY: stagger('-1em', { from: 'middle', direction: 'reverse' }),+ // delay: stagger(200, { from: 'middle', direction: 'reverse' }),+ // }, 0)+ // .add({+ // targets: '.from-index div',+ // translateY: stagger('-1em', {from: 2}),+ // delay: stagger(200, {from: 2})+ // }, 0)+ .add({+ targets: '.from-index-reversed div',+ //translateY: stagger('-1em', { from: 2, direction: 'reverse' }),+ translateY: 100,+ delay: stagger(200, { from: 2, direction: 'reverse' }),+ }, 0)+ // .add({+ // targets: '.range div',+ // translateY: stagger(['-2rem', '2em']),+ // delay: stagger([0, 1000])+ // }, 0)+ // .add({+ // targets: '.range-reversed div',+ // translateY: stagger(['-2rem', '2em'], { direction: 'reverse'}),+ // delay: stagger([0, 1000], { direction: 'reverse'}),+ // }, 0)+ // .add({+ // targets: '.range-from-last div',+ // translateY: stagger(['-2rem', '2em'], {from: 'last'}),+ // delay: stagger([0, 1000], {from: 'last'})+ // }, 0)+ // .add({+ // targets: '.range-from-last-reversed div',+ // translateY: stagger(['-2rem', '2em'], { from: 'last', direction: 'reverse'}),+ // delay: stagger([0, 1000], { from: 'last', direction: 'reverse'}),+ // }, 0)+ // .add({+ // targets: '.range-from-middle div',+ // translateY: stagger(['-2rem', '2em'], {from: 'middle'}),+ // delay: stagger([0, 1000], {from: 'middle'})+ // }, 0)+ // .add({+ // targets: '.range-from-middle-reversed div',+ // translateY: stagger(['-2rem', '2em'], { from: 'middle', direction: 'reverse'}),+ // delay: stagger([0, 1000], { from: 'middle', direction: 'reverse'}),+ // }, 0)+++ // var animation = anime({+ // targets: '.el',+ // //scaleY: stagger(.2, {from: 2, direction: 'reverse', start: 1}),+ // scale: .5,+ // //translateY: stagger(['-10rem', '10rem'], {from: 'middle', direction: 'reverse'}),+ // //translateY: stagger(1, {from: 'middle'}),+ // //delay: stagger([-100, 200], {direction: 'reverse', start: 1000}),+ // delay: stagger(80, {from: 2, direction: 'reverse'}),+ // easing: 'easeInOutQuad',+ // direction: 'alternate',+ // loop: true+ // });++ function animePlayer(instance, playerClass) {++ function createEl(type, className, parentEl) {+ var el = document.createElement(type);+ if (className) el.classList.add(className);+ if (parentEl) parentEl.appendChild(el);+ return el;+ }++ var timelineEl = createEl('div', 'timeline', document.body);+ if (playerClass) timelineEl.classList.add(playerClass);+ var needleEl = createEl('div', 'tl-needle', timelineEl);+ var animations = [];+ var colors = ['#FF1461','#FF7C72','#FBF38C','#A6FF8F','#18FF92','#1CE2B2','#5EF3FB','#61C3FF','#5A87FF','#8453E3','#C26EFF','#FB89FB'];+ var colorIndex = 0;++ function convertMStoEM(ms) { return ms / 100; }+ function convertEMtoMS(em) { return parseFloat(em) * 250; }++ function createAnimationLog(animObj, timelineOffset) {+ var anim = animObj;+ anim.player = {};+ anim.player.animationEl = createEl('div', 'tl-animation', timelineEl);+ anim.player.delayEl = createEl('div', 'tl-delay', anim.player.animationEl);+ anim.player.endDelayEl = createEl('div', 'tl-end-delay', anim.player.animationEl);+ anim.update = function() {+ anime.setValue(anim.player.animationEl, {+ left: convertMStoEM(timelineOffset) + 'em',+ width: convertMStoEM(anim.duration) + 'em'+ });+ anime.setValue(anim.player.delayEl, {width: (anim.delay / anim.duration) * 100 + '%'});+ anime.setValue(anim.player.endDelayEl, {width: (anim.endDelay / anim.duration) * 100 + '%'});+ }+ anime.setValue(anim.player.animationEl, {color: colors[colorIndex]});+ colorIndex++;+ if (!colors[colorIndex]) colorIndex = 0;+ anim.update();+ animations.push(anim);+ return anim;+ }++ instance.pause();++ var playerAnimation = anime({+ targets: needleEl,+ translateX: convertMStoEM(instance.duration) + 'em',+ duration: instance.duration,+ direction: instance.direction,+ loop: instance.loop,+ easing: 'linear',+ update: function(a) {+ instance.seek(a.currentTime);+ }+ });++ if (instance.children.length) {+ instance.children.forEach(function(child) {+ child.animations.forEach(function(anim) {+ createAnimationLog(anim, child.timelineOffset);+ });+ })+ } else {+ instance.animations.forEach(function(anim) {+ createAnimationLog(anim);+ });+ }++ }++ animePlayer(animations, 'player-animation');++</script>+</html>diff --git a/documentation/examples/anime-stagger-4.html b/documentation/examples/anime-stagger-4.htmlnew file mode 100644index 00000000..67c6161c--- /dev/null+++ b/documentation/examples/anime-stagger-4.html@@ -0,0 +1,500 @@+<!DOCTYPE html>+<html>+<head>+ <title>stagger | anime.js</title>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">+ <meta property="og:title" content="anime.js">+ <meta property="og:url" content="http://animejs.com">+ <meta property="og:description" content="Javascript Animation Engine">+ <meta property="og:image" content="http://animejs.com/documentation/assets/img/icons/og.png">+ <meta name="twitter:card" content="summary">+ <meta name="twitter:title" content="anime.js">+ <meta name="twitter:site" content="@juliangarnier">+ <meta name="twitter:description" content="Javascript Animation Engine">+ <meta name="twitter:image" content="http://animejs.com/documentation/assets/img/icons/twitter.png">+ <link rel="apple-touch-icon-precomposed" href="../assets/img/icons/apple-touch-icon.png">+ <link rel="icon" type="image/png" href="../assets/img/icons/favicon.png" >+ <link href="../assets/css/documentation.css" rel="stylesheet">+ <style>++ body {+ display: flex;+ flex-wrap: wrap;+ justify-content: center;+ align-items: center;+ }++ .testarea {+ display: flex;+ flex-direction: row;+ align-items: center;+ flex-wrap: wrap;+ flex-shrink: 0;+ width: 100%;+ height: 100%;+ }++ .demo {+ flex-wrap: wrap;+ position: relative;+ align-items: center;+ width: 14rem;+ height: 4rem;+ padding: 2rem;+ }++ .demo-title {+ position: absolute;+ top: 0;+ left: 2rem;+ }++ .demo div {+ width: 1rem;+ height: 1rem;+ /*background-color: currentColor;*/+ border: 2px solid currentColor;+ }++ .from-coords, .from-coords-reversed {+ padding: 3rem 3rem;+ }++ /* Player animation */++ .timeline {+ opacity: .2;+ position: fixed;+ flex-shrink: 0;+ width: 100%;+ height: 100%;+ padding-top: 4px;+ }++ .timeline.player-animation {+ width: 100%;+ left: 0;+ }++ .tl-needle {+ position: fixed;+ z-index: 2;+ top: 0;+ left: 0;+ width: 2px;+ height: 100%;+ margin-left: -1px;+ background-color: #FFF;+ }++ .tl-animation {+ position: relative;+ display: flex;+ justify-content: space-between;+ width: auto;+ height: 8px;+ margin-bottom: 4px;+ background-color: currentColor;+ border-radius: .5rem;+ }++ .tl-delay,+ .tl-end-delay {+ width: auto;+ height: 100%;+ background-color: rgba(0,0,0,.5);+ }++ </style>+</head>+<body>++ <div class="player-animation"></div>++ <div class="testarea">++ <section class="demo normal">+ <h1 class="demo-title">Normal</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo normal-reversed">+ <h1 class="demo-title">Normal reversed</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-last">+ <h1 class="demo-title">From last</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-last-reversed">+ <h1 class="demo-title">From last reversed</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-middle">+ <h1 class="demo-title">From middle</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-middle-reversed">+ <h1 class="demo-title">From middle reversed</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-index">+ <h1 class="demo-title">From index</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-index-reversed">+ <h1 class="demo-title">From index reversed</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo range">+ <h1 class="demo-title">Range</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo range-reversed">+ <h1 class="demo-title">Range reversed</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo range-from-last">+ <h1 class="demo-title">Range from last</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo range-from-last-reversed">+ <h1 class="demo-title">Range from last reversed</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo range-from-middle">+ <h1 class="demo-title">Range from middle</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo range-from-middle-reversed">+ <h1 class="demo-title">Range from middle reversed</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo easing">+ <h1 class="demo-title">Easing</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo easing-reversed">+ <h1 class="demo-title">Easing reversed</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-coords">+ <h1 class="demo-title">Coordinates</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-coords-reversed">+ <h1 class="demo-title">Coordinates reversed</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ </div>++</body>+<script type="module">++ import anime from '../../src/index.js';++ // var animationTimeLogEl = document.querySelector('.time-animation');+ // var timelineTimeLogEl = document.querySelector('.time-timeline');++ // var testAreaEl = document.querySelector('.testarea');+ // var fragment = document.createDocumentFragment();+ // var colorIndex = 1;++ // for (var i = 0; i < 10; i++) {+ // var el = document.createElement('div');+ // el.classList.add('el');+ // el.classList.add('color-'+('0' + colorIndex).slice(-2));+ // colorIndex++;+ // if (colorIndex > 12) colorIndex = 1;+ // fragment.appendChild(el);+ // }++ // testAreaEl.appendChild(fragment);++ // splash: (x, y, spacing) => {+ // return (el, i) => {+ // const rect = el.getBoundingClientRect();+ // const dx = x - (rect.left + (rect.width / 2));+ // const dy = y - (rect.top + (rect.height / 2));+ // const distance = Math.sqrt( dx * dx + dy * dy );+ // return (distance / 100) * spacing;+ // }++ 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))+ }++ 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 stagger(val, params = {}) {+ const direction = params.direction || 'normal';+ const grid = params.grid;+ const isRange = is.arr(val);+ const val1 = isRange ? parseFloat(val[0]) : parseFloat(val);+ const val2 = isRange ? parseFloat(val[1]) : 0;+ const start = params.start || 0 + (isRange ? val1 : 0);+ const easing = params.easing ? anime.easing(params.easing) : null;+ const unit = getUnit(isRange ? val[1] : val) || 0;+ const getCoords el => {+ const rect = el.getBoundingClientRect();+ return {x: rect.left + (rect.width / 2), y: rect.top + (rect.height / 2)}+ }+ const values = [];+ let maxValue = 0;+ let from = params.from || 0;+ let intialValue = from;+ return (el, i, t) => {+ if (from === 'middle') intialValue = (t - 1) / 2;+ if (from === 'last') intialValue = t - 1;+ if (!values.length) {+ for (let index = 0; index < t; index++) {+ if (grid) {+ const x = intialValue%grid[0];+ const y = Math.ceil(intialValue/grid[1]);+ // const x = 3.5;+ // const y = 4.5;+ const dx = x - index%grid[0];+ const dy = y - Math.ceil(index/grid[1]);+ console.log(x, y, index%grid[0]);+ values.push(Math.sqrt(dx * dx + dy * dy));+ } else {+ values.push(Math.abs(intialValue - index));+ }+ maxValue = Math.max(...values);+ }+ }+ let progress = values[i];+ if (easing) progress = easing(progress / maxValue) * maxValue;+ if (direction === 'reverse') progress = Math.abs(maxValue - progress);+ const spacing = isRange ? (val2 - val1) / maxValue : val1;+ return start + (spacing * progress) + unit;+ }+ }++ var animations = anime.timeline({+ easing: 'easeInOutQuad',+ //direction: 'alternate',+ //loop: true+ })+ // .add({+ // targets: '.normal div',+ // translateY: stagger('-.5em'),+ // delay: stagger(200)+ // }, 0)+ // .add({+ // targets: '.normal-reversed div',+ // translateY: stagger('-.5em', { direction: 'reverse' }),+ // delay: stagger(200, { direction: 'reverse' }),+ // }, 0)+ // .add({+ // targets: '.from-last div',+ // translateY: stagger('-.5em', {from: 'last'}),+ // delay: stagger(200, {from: 'last'})+ // }, 0)+ // .add({+ // targets: '.from-last-reversed div',+ // translateY: stagger('-.5em', { from: 'last', direction: 'reverse' }),+ // delay: stagger(200, { from: 'last', direction: 'reverse' }),+ // }, 0)+ // .add({+ // targets: '.from-middle div',+ // translateY: stagger('-.5em', {from: 'middle'}),+ // delay: stagger(200, {from: 'middle'})+ // }, 0)+ // .add({+ // targets: '.from-middle-reversed div',+ // translateY: stagger('-.5em', { from: 'middle', direction: 'reverse' }),+ // delay: stagger(200, { from: 'middle', direction: 'reverse' }),+ // }, 0)+ // .add({+ // targets: '.from-index div',+ // translateY: stagger('-.5em', {from: 3}),+ // delay: stagger(200, {from: 3})+ // }, 0)+ // .add({+ // targets: '.from-index-reversed div',+ // translateY: stagger('-.5em', { from: 3, direction: 'reverse' }),+ // delay: stagger(200, { from: 3, direction: 'reverse' }),+ // }, 0)+ // .add({+ // targets: '.range div',+ // translateY: stagger(['-2em', '2em']),+ // delay: stagger([0, 1000])+ // }, 0)+ // .add({+ // targets: '.range-reversed div',+ // translateY: stagger(['-2em', '2em'], { direction: 'reverse'}),+ // delay: stagger([0, 1000], { direction: 'reverse'}),+ // }, 0)+ // .add({+ // targets: '.range-from-last div',+ // translateY: stagger(['-2em', '2em'], {from: 'last'}),+ // delay: stagger([0, 1000], {from: 'last'})+ // }, 0)+ // .add({+ // targets: '.range-from-last-reversed div',+ // translateY: stagger(['-2em', '2em'], { from: 'last', direction: 'reverse'}),+ // delay: stagger([0, 1000], { from: 'last', direction: 'reverse'}),+ // }, 0)+ // .add({+ // targets: '.range-from-middle div',+ // translateY: stagger(['-2em', '2em'], {from: 'middle'}),+ // delay: stagger([0, 1000], {from: 'middle'})+ // }, 0)+ // .add({+ // targets: '.range-from-middle-reversed div',+ // translateY: stagger(['-2em', '2em'], { from: 'middle', direction: 'reverse'}),+ // delay: stagger([0, 1000], { from: 'middle', direction: 'reverse'}),+ // }, 0)+ // .add({+ // targets: '.easing div',+ // translateY: stagger(['2em', '-2em'], {easing: 'easeInOutQuart'}),+ // delay: stagger(200, {easing: 'easeInOutQuart'})+ // }, 0)+ // .add({+ // targets: '.easing-reversed div',+ // translateY: stagger(['2em', '-2em'], { direction: 'reverse', easing: 'easeInOutQuart'}),+ // delay: stagger(200, { direction: 'reverse', easing: 'easeInOutQuart'}),+ // }, 0)+ .add({+ targets: '.from-coords div',+ scale: stagger([0, 1], {grid: [8, 6], from: 19.5}),+ delay: stagger(200, {grid: [8, 6], from: 19.5})+ }, 0)+ .add({+ targets: '.from-coords-reversed div',+ scale: stagger([0, 1], {grid: [8, 6], direction: 'reverse'}),+ delay: stagger(200, {grid: [8, 6], direction: 'reverse'})+ }, 0)+ // .add({+ // targets: '.from-coords-reversed div',+ // scale: stagger([.1, 1], { direction: 'reverse', from: 'middle'}),+ // delay: stagger(200, { direction: 'reverse', from: 'middle'}),+ // }, 0)++ // var animation = anime({+ // targets: '.el',+ // //scaleY: stagger(.2, {from: 2, direction: 'reverse', start: 1}),+ // scale: .5,+ // //translateY: stagger(['-10rem', '10rem'], {from: 'middle', direction: 'reverse'}),+ // //translateY: stagger(1, {from: 'middle'}),+ // //delay: stagger([-100, 200], {direction: 'reverse', start: 1000}),+ // delay: stagger(80, {from: 2, direction: 'reverse'}),+ // easing: 'easeInOutQuad',+ // direction: 'alternate',+ // loop: true+ // });++ function animePlayer(instance, playerClass) {++ function createEl(type, className, parentEl) {+ var el = document.createElement(type);+ if (className) el.classList.add(className);+ if (parentEl) parentEl.appendChild(el);+ return el;+ }++ var timelineEl = createEl('div', 'timeline', document.body);+ if (playerClass) timelineEl.classList.add(playerClass);+ var needleEl = createEl('div', 'tl-needle', timelineEl);+ var animations = [];+ var colors = ['#FF1461','#FF7C72','#FBF38C','#A6FF8F','#18FF92','#1CE2B2','#5EF3FB','#61C3FF','#5A87FF','#8453E3','#C26EFF','#FB89FB'];+ var colorIndex = 0;++ function convertMStoEM(ms) { return ms / 100; }+ function convertEMtoMS(em) { return parseFloat(em) * 250; }++ function createAnimationLog(animObj, timelineOffset) {+ var anim = animObj;+ anim.player = {};+ anim.player.animationEl = createEl('div', 'tl-animation', timelineEl);+ anim.player.delayEl = createEl('div', 'tl-delay', anim.player.animationEl);+ anim.player.endDelayEl = createEl('div', 'tl-end-delay', anim.player.animationEl);+ anim.update = function() {+ anime.setValue(anim.player.animationEl, {+ left: convertMStoEM(timelineOffset) + 'em',+ width: convertMStoEM(anim.duration) + 'em'+ });+ anime.setValue(anim.player.delayEl, {width: (anim.delay / anim.duration) * 100 + '%'});+ anime.setValue(anim.player.endDelayEl, {width: (anim.endDelay / anim.duration) * 100 + '%'});+ }+ anime.setValue(anim.player.animationEl, {color: colors[colorIndex]});+ colorIndex++;+ if (!colors[colorIndex]) colorIndex = 0;+ anim.update();+ animations.push(anim);+ return anim;+ }++ instance.pause();++ var playerAnimation = anime({+ targets: needleEl,+ translateX: convertMStoEM(instance.duration) + 'em',+ duration: instance.duration,+ direction: instance.direction,+ loop: instance.loop,+ easing: 'linear',+ update: function(a) {+ instance.seek(a.currentTime);+ }+ });++ if (instance.children.length) {+ instance.children.forEach(function(child) {+ child.animations.forEach(function(anim) {+ createAnimationLog(anim, child.timelineOffset);+ });+ })+ } else {+ instance.animations.forEach(function(anim) {+ createAnimationLog(anim);+ });+ }++ }++ animePlayer(animations, 'player-animation');++</script>+</html>diff --git a/documentation/examples/anime-stagger-5.html b/documentation/examples/anime-stagger-5.htmlnew file mode 100644index 00000000..671725e5--- /dev/null+++ b/documentation/examples/anime-stagger-5.html@@ -0,0 +1,394 @@+<!DOCTYPE html>+<html>+<head>+ <title>stagger | anime.js</title>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">+ <meta property="og:title" content="anime.js">+ <meta property="og:url" content="http://animejs.com">+ <meta property="og:description" content="Javascript Animation Engine">+ <meta property="og:image" content="http://animejs.com/documentation/assets/img/icons/og.png">+ <meta name="twitter:card" content="summary">+ <meta name="twitter:title" content="anime.js">+ <meta name="twitter:site" content="@juliangarnier">+ <meta name="twitter:description" content="Javascript Animation Engine">+ <meta name="twitter:image" content="http://animejs.com/documentation/assets/img/icons/twitter.png">+ <link rel="apple-touch-icon-precomposed" href="../assets/img/icons/apple-touch-icon.png">+ <link rel="icon" type="image/png" href="../assets/img/icons/favicon.png" >+ <link href="../assets/css/documentation.css" rel="stylesheet">+ <style>++ body {+ display: flex;+ flex-wrap: wrap;+ justify-content: center;+ align-items: center;+ }++ .testarea {+ display: flex;+ flex-direction: row;+ align-items: center;+ flex-wrap: wrap;+ flex-shrink: 0;+ width: 100%;+ height: 100%;+ }++ .demo {+ flex-wrap: wrap;+ position: relative;+ align-items: center;+ flex-grow: 1;+ width: 14rem;+ height: 4rem;+ padding: 2rem;+ border-bottom: none;+ }++ .demo h1 {+ position: absolute;+ top: 0;+ left: 0;+ right: 0;+ text-align: center;+ }++ .demo div {+ width: 1rem;+ height: 1rem;+ /*background-color: currentColor;*/+ border: 2px solid currentColor;+ }++ .from-coords, .from-coords-reversed {+ padding: 3rem 3.5rem;+ }++ /* Player animation */++ .timeline {+ opacity: .2;+ position: fixed;+ flex-shrink: 0;+ width: 100%;+ height: 100%;+ padding-top: 4px;+ }++ .timeline.player-animation {+ width: 100%;+ left: 0;+ }++ .tl-needle {+ position: fixed;+ z-index: 2;+ top: 0;+ left: 0;+ width: 2px;+ height: 100%;+ margin-left: -1px;+ background-color: #FFF;+ }++ .tl-animation {+ position: relative;+ display: flex;+ justify-content: space-between;+ width: auto;+ height: 8px;+ margin-bottom: 4px;+ background-color: currentColor;+ border-radius: .5rem;+ }++ .tl-delay,+ .tl-end-delay {+ width: auto;+ height: 100%;+ background-color: rgba(0,0,0,.5);+ }++ </style>+</head>+<body>++ <div class="player-animation"></div>++ <div class="testarea">++ <section class="demo normal">+ <h1>Normal</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo normal-reversed">+ <h1>Normal reversed</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-last">+ <h1>From last</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-last-reversed">+ <h1>From last reversed</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-center">+ <h1>From center</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-center-reversed">+ <h1>From center reversed</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-index">+ <h1>From index</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-index-reversed">+ <h1>From index reversed</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo range">+ <h1>Range</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo range-reversed">+ <h1>Range reversed</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo range-from-last">+ <h1>Range from last</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo range-from-last-reversed">+ <h1>Range from last reversed</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo range-from-center">+ <h1>Range from center</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo range-from-center-reversed">+ <h1>Range from center reversed</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo easing">+ <h1>Easing</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo easing-reversed">+ <h1>Easing reversed</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-coords">+ <h1>Coordinates</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ <section class="demo from-coords-reversed">+ <h1>Coordinates reversed</h1>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>+ </section>++ </div>++</body>+<script type="module">++ import anime from '../../src/index.js';++ var animations = anime.timeline({+ easing: 'easeInOutQuad',+ direction: 'alternate',+ loop: true+ })+ .add({+ targets: '.normal div',+ translateY: anime.stagger('-.5em'),+ delay: anime.stagger(200)+ }, 0)+ .add({+ targets: '.normal-reversed div',+ translateY: anime.stagger('-.5em', { direction: 'reverse' }),+ delay: anime.stagger(200, { direction: 'reverse' }),+ }, 0)+ .add({+ targets: '.from-last div',+ translateY: anime.stagger('-.5em', {from: 'last'}),+ delay: anime.stagger(200, {from: 'last'})+ }, 0)+ .add({+ targets: '.from-last-reversed div',+ translateY: anime.stagger('-.5em', { from: 'last', direction: 'reverse' }),+ delay: anime.stagger(200, { from: 'last', direction: 'reverse' }),+ }, 0)+ .add({+ targets: '.from-center div',+ translateY: anime.stagger('-.5em', {from: 'center'}),+ delay: anime.stagger(200, {from: 'center'})+ }, 0)+ .add({+ targets: '.from-center-reversed div',+ translateY: anime.stagger('-.5em', { from: 'center', direction: 'reverse' }),+ delay: anime.stagger(200, { from: 'center', direction: 'reverse' }),+ }, 0)+ .add({+ targets: '.from-index div',+ translateY: anime.stagger('-.5em', {from: 3}),+ delay: anime.stagger(200, {from: 3})+ }, 0)+ .add({+ targets: '.from-index-reversed div',+ translateY: anime.stagger('-.5em', { from: 3, direction: 'reverse' }),+ delay: anime.stagger(200, { from: 3, direction: 'reverse' }),+ }, 0)+ .add({+ targets: '.range div',+ translateY: anime.stagger(['-2em', '2em']),+ delay: anime.stagger([0, 600])+ }, 0)+ .add({+ targets: '.range-reversed div',+ translateY: anime.stagger(['-2em', '2em'], { direction: 'reverse'}),+ delay: anime.stagger([0, 600], { direction: 'reverse'}),+ }, 0)+ .add({+ targets: '.range-from-last div',+ translateY: anime.stagger(['-2em', '2em'], {from: 'last'}),+ delay: anime.stagger([0, 600], {from: 'last'})+ }, 0)+ .add({+ targets: '.range-from-last-reversed div',+ translateY: anime.stagger(['-2em', '2em'], { from: 'last', direction: 'reverse'}),+ delay: anime.stagger([0, 600], { from: 'last', direction: 'reverse'}),+ }, 0)+ .add({+ targets: '.range-from-center div',+ translateY: anime.stagger(['-2em', '2em'], {from: 'center'}),+ delay: anime.stagger([0, 600], {from: 'center'})+ }, 0)+ .add({+ targets: '.range-from-center-reversed div',+ translateY: anime.stagger(['-2em', '2em'], { from: 'center', direction: 'reverse'}),+ delay: anime.stagger([0, 600], { from: 'center', direction: 'reverse'}),+ }, 0)+ .add({+ targets: '.easing div',+ translateY: anime.stagger(['2em', '-2em'], {easing: 'easeInOutQuart'}),+ delay: anime.stagger([0, 600], {easing: 'easeInOutQuart'})+ }, 0)+ .add({+ targets: '.easing-reversed div',+ translateY: anime.stagger(['2em', '-2em'], { direction: 'reverse', easing: 'easeInOutQuart'}),+ delay: anime.stagger([0, 600], { direction: 'reverse', easing: 'easeInOutQuart'}),+ }, 0)+ .add({+ targets: '.from-coords div',+ scale: anime.stagger([0, 1], {grid: [7, 7], from: 'center'}),+ delay: anime.stagger(200, {grid: [7, 7], from: 'center'})+ }, 0)+ .add({+ targets: '.from-coords-reversed div',+ scale: anime.stagger([0, 1], {grid: [7, 7], from: 'center', direction: 'reverse'}),+ delay: anime.stagger(200, {grid: [7, 7], from: 'center', direction: 'reverse'})+ }, 0);++ function animePlayer(instance, playerClass) {++ function createEl(type, className, parentEl) {+ var el = document.createElement(type);+ if (className) el.classList.add(className);+ if (parentEl) parentEl.appendChild(el);+ return el;+ }++ var timelineEl = createEl('div', 'timeline', document.body);+ if (playerClass) timelineEl.classList.add(playerClass);+ var needleEl = createEl('div', 'tl-needle', timelineEl);+ var animations = [];+ var colors = ['#FF1461','#FF7C72','#FBF38C','#A6FF8F','#18FF92','#1CE2B2','#5EF3FB','#61C3FF','#5A87FF','#8453E3','#C26EFF','#FB89FB'];+ var colorIndex = 0;++ function convertMStoEM(ms) { return ms / 100; }+ function convertEMtoMS(em) { return parseFloat(em) * 250; }++ function createAnimationLog(animObj, timelineOffset) {+ var anim = animObj;+ anim.player = {};+ anim.player.animationEl = createEl('div', 'tl-animation', timelineEl);+ anim.player.delayEl = createEl('div', 'tl-delay', anim.player.animationEl);+ anim.player.endDelayEl = createEl('div', 'tl-end-delay', anim.player.animationEl);+ anim.update = function() {+ anime.setValue(anim.player.animationEl, {+ left: convertMStoEM(timelineOffset) + 'em',+ width: convertMStoEM(anim.duration) + 'em'+ });+ anime.setValue(anim.player.delayEl, {width: (anim.delay / anim.duration) * 100 + '%'});+ anime.setValue(anim.player.endDelayEl, {width: (anim.endDelay / anim.duration) * 100 + '%'});+ }+ anime.setValue(anim.player.animationEl, {color: colors[colorIndex]});+ colorIndex++;+ if (!colors[colorIndex]) colorIndex = 0;+ anim.update();+ animations.push(anim);+ return anim;+ }++ instance.pause();++ var playerAnimation = anime({+ targets: needleEl,+ translateX: convertMStoEM(instance.duration) + 'em',+ duration: instance.duration,+ direction: instance.direction,+ loop: instance.loop,+ easing: 'linear',+ update: function(a) {+ instance.seek(a.currentTime);+ }+ });++ if (instance.children.length) {+ instance.children.forEach(function(child) {+ child.animations.forEach(function(anim) {+ createAnimationLog(anim, child.timelineOffset);+ });+ })+ } else {+ instance.animations.forEach(function(anim) {+ createAnimationLog(anim);+ });+ }++ }++ animePlayer(animations, 'player-animation');++</script>+</html>diff --git a/documentation/examples/anime-stagger.html b/documentation/examples/anime-stagger.htmlnew file mode 100644index 00000000..f15c4901--- /dev/null+++ b/documentation/examples/anime-stagger.html@@ -0,0 +1,437 @@+<!DOCTYPE html>+<html>+<head>+ <title>stagger | anime.js</title>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">+ <meta property="og:title" content="anime.js">+ <meta property="og:url" content="http://animejs.com">+ <meta property="og:description" content="Javascript Animation Engine">+ <meta property="og:image" content="http://animejs.com/documentation/assets/img/icons/og.png">+ <meta name="twitter:card" content="summary">+ <meta name="twitter:title" content="anime.js">+ <meta name="twitter:site" content="@juliangarnier">+ <meta name="twitter:description" content="Javascript Animation Engine">+ <meta name="twitter:image" content="http://animejs.com/documentation/assets/img/icons/twitter.png">+ <link rel="apple-touch-icon-precomposed" href="../assets/img/icons/apple-touch-icon.png">+ <link rel="icon" type="image/png" href="../assets/img/icons/favicon.png" >+ <link href="../assets/css/documentation.css" rel="stylesheet">+ <style>++ body {+ display: flex;+ flex-wrap: wrap;+ justify-content: center;+ align-items: center;+ position: absolute;+ width: 100%;+ height: 100%;+ }++ .testarea {+ position: fixed;+ z-index: 1;+ display: flex;+ flex-wrap: wrap;+ justify-content: center;+ align-items: center;+ flex-shrink: 0;+ width: calc( 14 * 3rem);+ height: calc( 14 * 3rem);+ }++ .el {+ width: 3rem;+ height: 3rem;+ background-color: currentColor;+ }++ /* Player animation */++ .timeline {+ position: absolute;+ flex-shrink: 0;+ width: 100%;+ height: 100%;+ padding-top: 4px;+ }++ .timeline.player-animation {+ width: 100%;+ left: 0;+ }++ .tl-needle {+ position: fixed;+ z-index: 2;+ top: 0;+ left: 0;+ width: 2px;+ height: 100%;+ margin-left: -1px;+ background-color: #FFF;+ }++ .tl-animation {+ position: relative;+ display: flex;+ justify-content: space-between;+ width: auto;+ height: 8px;+ margin-bottom: 4px;+ background-color: currentColor;+ border-radius: .5rem;+ }++ .tl-delay,+ .tl-end-delay {+ width: auto;+ height: 100%;+ background-color: rgba(0,0,0,.5);+ }++ </style>+</head>+<body>++ <div class="testarea">++ <div class="el color-01"></div>+ <div class="el color-02"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>+ <div class="el color-06"></div>+ <div class="el color-07"></div>+ <div class="el color-08"></div>+ <div class="el color-09"></div>+ <div class="el color-10"></div>+ <div class="el color-11"></div>+ <div class="el color-01"></div>+ <div class="el color-02"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>+ <div class="el color-06"></div>+ <div class="el color-07"></div>+ <div class="el color-08"></div>+ <div class="el color-09"></div>+ <div class="el color-10"></div>+ <div class="el color-11"></div>+ <div class="el color-01"></div>+ <div class="el color-02"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>+ <div class="el color-06"></div>+ <div class="el color-07"></div>+ <div class="el color-08"></div>+ <div class="el color-09"></div>+ <div class="el color-10"></div>+ <div class="el color-11"></div>+ <div class="el color-01"></div>+ <div class="el color-02"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>+ <div class="el color-06"></div>+ <div class="el color-07"></div>+ <div class="el color-08"></div>+ <div class="el color-09"></div>+ <div class="el color-10"></div>+ <div class="el color-11"></div>+ <div class="el color-01"></div>+ <div class="el color-02"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>+ <div class="el color-06"></div>+ <div class="el color-07"></div>+ <div class="el color-08"></div>+ <div class="el color-09"></div>+ <div class="el color-10"></div>+ <div class="el color-11"></div>+ <div class="el color-01"></div>+ <div class="el color-02"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>+ <div class="el color-06"></div>+ <div class="el color-07"></div>+ <div class="el color-08"></div>+ <div class="el color-09"></div>+ <div class="el color-10"></div>+ <div class="el color-11"></div>+ <div class="el color-01"></div>+ <div class="el color-02"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>+ <div class="el color-06"></div>+ <div class="el color-07"></div>+ <div class="el color-08"></div>+ <div class="el color-09"></div>+ <div class="el color-10"></div>+ <div class="el color-11"></div>+ <div class="el color-01"></div>+ <div class="el color-02"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>+ <div class="el color-06"></div>+ <div class="el color-07"></div>+ <div class="el color-08"></div>+ <div class="el color-09"></div>+ <div class="el color-10"></div>+ <div class="el color-11"></div>+ <div class="el color-01"></div>+ <div class="el color-02"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>+ <div class="el color-06"></div>+ <div class="el color-07"></div>+ <div class="el color-08"></div>+ <div class="el color-09"></div>+ <div class="el color-10"></div>+ <div class="el color-11"></div>+ <div class="el color-01"></div>+ <div class="el color-02"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>+ <div class="el color-06"></div>+ <div class="el color-07"></div>+ <div class="el color-08"></div>+ <div class="el color-09"></div>+ <div class="el color-10"></div>+ <div class="el color-11"></div>+ <div class="el color-01"></div>+ <div class="el color-02"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>+ <div class="el color-06"></div>+ <div class="el color-07"></div>+ <div class="el color-08"></div>+ <div class="el color-09"></div>+ <div class="el color-10"></div>+ <div class="el color-11"></div>+ <div class="el color-01"></div>+ <div class="el color-02"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>+ <div class="el color-06"></div>+ <div class="el color-07"></div>+ <div class="el color-08"></div>+ <div class="el color-09"></div>+ <div class="el color-10"></div>+ <div class="el color-11"></div>+ <div class="el color-01"></div>+ <div class="el color-02"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>+ <div class="el color-06"></div>+ <div class="el color-07"></div>+ <div class="el color-08"></div>+ <div class="el color-09"></div>+ <div class="el color-10"></div>+ <div class="el color-11"></div>+ <div class="el color-01"></div>+ <div class="el color-02"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>+ <div class="el color-06"></div>+ <div class="el color-07"></div>+ <div class="el color-08"></div>+ <div class="el color-09"></div>+ <div class="el color-10"></div>+ <div class="el color-11"></div>+ <div class="el color-01"></div>+ <div class="el color-02"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>+ <div class="el color-06"></div>+ <div class="el color-07"></div>+ <div class="el color-08"></div>+ <div class="el color-09"></div>+ <div class="el color-10"></div>+ <div class="el color-11"></div>+ <div class="el color-01"></div>+ <div class="el color-02"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>+ <div class="el color-06"></div>+ <div class="el color-07"></div>+ <div class="el color-08"></div>+ <div class="el color-09"></div>+ <div class="el color-10"></div>+ <div class="el color-11"></div>+ <div class="el color-01"></div>+ <div class="el color-02"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>+ <div class="el color-06"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>+ <div class="el color-06"></div>+ <div class="el color-07"></div>+ <div class="el color-08"></div>+ <div class="el color-09"></div>+ <div class="el color-10"></div>+ <div class="el color-11"></div>+ <div class="el color-01"></div>+ <div class="el color-02"></div>+ <div class="el color-03"></div>+ <div class="el color-04"></div>+ <div class="el color-05"></div>++ </div>++ <div class="log log-animation"></div>+ <div class="time time-animation"></div>++</body>+<script type="module">++ import anime from '../../src/index.js';++ var animationTimeLogEl = document.querySelector('.time-animation');+ var timelineTimeLogEl = document.querySelector('.time-timeline');++ var stagger = {+ leftToRight: (spacing, min, max) => {+ return (el, i, t) => {+ let delay = i * spacing;+ if (min) delay += min;+ if (max) delay = i * ((max - min) / t);+ return delay;+ }+ },+ rightToLeft: spacing => {+ return (el, i, t) => {+ return ((t - 1) - i) * spacing;+ }+ },+ centerOut: spacing => {+ return (el, i, t) => {+ return Math.abs(Math.round((t / 2) - i - 1)) * spacing+ }+ },+ centerIn: spacing => {+ return (el, i, t) => {+ return (i >= t / 2 ? ((t - 1) - i) : i) * spacing+ }+ },+ splash: (x, y, spacing) => {+ return (el, i) => {+ const rect = el.getBoundingClientRect();+ const dx = x - (rect.left + (rect.width / 2));+ const dy = y - (rect.top + (rect.height / 2));+ const distance = Math.sqrt( dx * dx + dy * dy );+ return (distance / 100) * spacing;+ }+ }+ }++ // anime.stagger(0, 1, 100);+ // anime.stagger(1, 0, 100);+ // anime.stagger(.5, 1, 100);+ // anime.stagger(1, .5, 100);+ // anime.stagger({x: window.innerWidth / 2, y: window.innerWidth / 2}, 1, 100);+ // anime.stagger('-2rem', '2rem');++ // anime.stagger.linear(100, true);+ // anime.stagger.splash();++ var animation = anime({+ targets: '.el',+ rotate: stagger.splash(window.innerWidth / 2, window.innerHeight / 2, 90),+ scaleX: .05,+ delay: stagger.splash(window.innerWidth / 2, window.innerHeight / 2, 100),+ easing: 'easeInOutQuart',+ direction: 'alternate',+ loop: true+ });++ function animePlayer(instance, playerClass) {++ function createEl(type, className, parentEl) {+ var el = document.createElement(type);+ if (className) el.classList.add(className);+ if (parentEl) parentEl.appendChild(el);+ return el;+ }++ var timelineEl = createEl('div', 'timeline', document.body);+ if (playerClass) timelineEl.classList.add(playerClass);+ var needleEl = createEl('div', 'tl-needle', timelineEl);+ var animations = [];+ var colors = ['#FF1461','#FF7C72','#FBF38C','#A6FF8F','#18FF92','#1CE2B2','#5EF3FB','#61C3FF','#5A87FF','#8453E3','#C26EFF','#FB89FB'];+ var colorIndex = 0;++ function convertMStoEM(ms) { return ms / 100; }+ function convertEMtoMS(em) { return parseFloat(em) * 250; }++ function createAnimationLog(animObj, timelineOffset) {+ var anim = animObj;+ anim.player = {};+ anim.player.animationEl = createEl('div', 'tl-animation', timelineEl);+ anim.player.delayEl = createEl('div', 'tl-delay', anim.player.animationEl);+ anim.player.endDelayEl = createEl('div', 'tl-end-delay', anim.player.animationEl);+ anim.update = function() {+ anime.setValue(anim.player.animationEl, {+ left: convertMStoEM(timelineOffset) + 'em',+ width: convertMStoEM(anim.duration) + 'em'+ });+ anime.setValue(anim.player.delayEl, {width: (anim.delay / anim.duration) * 100 + '%'});+ anime.setValue(anim.player.endDelayEl, {width: (anim.endDelay / anim.duration) * 100 + '%'});+ }+ anime.setValue(anim.player.animationEl, {color: colors[colorIndex]});+ colorIndex++;+ if (!colors[colorIndex]) colorIndex = 0;+ anim.update();+ animations.push(anim);+ return anim;+ }++ instance.pause();++ var playerAnimation = anime({+ targets: needleEl,+ translateX: convertMStoEM(instance.duration) + 'em',+ duration: instance.duration,+ direction: instance.direction,+ loop: instance.loop,+ easing: 'linear',+ update: function(a) {+ instance.seek(a.currentTime);+ }+ });++ if (instance.children.length) {+ instance.children.forEach(function(child) {+ console.log(child.timelineOffset);+ child.animations.forEach(function(anim) {+ createAnimationLog(anim, child.timelineOffset);+ });+ })+ } else {+ instance.animations.forEach(function(anim) {+ createAnimationLog(anim);+ });+ }++ }++ animePlayer(animation, 'player-animation');++</script>+</html>diff --git a/documentation/examples/anime-staggering-demo.html b/documentation/examples/anime-staggering-demo.htmlnew file mode 100644index 00000000..d3c9da40--- /dev/null+++ b/documentation/examples/anime-staggering-demo.html@@ -0,0 +1,147 @@+<!DOCTYPE html>+<html>+<head>+ <title>stagger | anime.js</title>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">+ <meta property="og:title" content="anime.js">+ <meta property="og:url" content="http://animejs.com">+ <meta property="og:description" content="Javascript Animation Engine">+ <meta property="og:image" content="http://animejs.com/documentation/assets/img/icons/og.png">+ <meta name="twitter:card" content="summary">+ <meta name="twitter:title" content="anime.js">+ <meta name="twitter:site" content="@juliangarnier">+ <meta name="twitter:description" content="Javascript Animation Engine">+ <meta name="twitter:image" content="http://animejs.com/documentation/assets/img/icons/twitter.png">+ <link rel="apple-touch-icon-precomposed" href="../assets/img/icons/apple-touch-icon.png">+ <link rel="icon" type="image/png" href="../assets/img/icons/favicon.png" >+ <link href="../assets/css/documentation.css" rel="stylesheet">+ <style>++ body {+ display: flex;+ flex-wrap: wrap;+ justify-content: center;+ align-items: center;+ }++ .easing-visualizer {+ display: flex;+ justify-content: space-between;+ align-items: flex-end;+ width: 400px;+ height: 400px;+ }++ .easing-visualizer div {+ width: 4px;+ height: 4px;+ margin: 0 0 0 0;+ background-color: #FFF;+ transform-origin: 50% 100%;+ border-radius: 50%;+ }++ </style>+</head>+<body>++ <div class="easing-visualizer"></div>++</body>+<script type="module">++ import anime from '../../src/index.js';++ 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))+ }++ 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 stagger(val, params = {}) {+ const direction = params.direction || 'normal';+ const grid = params.grid;+ const isRange = is.arr(val);+ const val1 = isRange ? parseFloat(val[0]) : parseFloat(val);+ const val2 = isRange ? parseFloat(val[1]) : 0;+ const start = params.start || 0 + (isRange ? val1 : 0);+ const easing = params.easing ? anime.easing(params.easing) : null;+ const unit = getUnit(isRange ? val[1] : val) || 0;+ const values = [];+ let maxValue = 0;+ let from = params.from || 0;+ let intialValue = from;+ return (el, i, t) => {+ if (from === 'middle') intialValue = (t - 1) / 2;+ if (from === 'last') intialValue = t - 1;+ if (!values.length) {+ for (let index = 0; index < t; index++) {+ if (grid) {+ // const x = from !== 'middle' ? intialValue%grid[0] : (grid[0]/2)%grid[0];+ // const y = from !== 'middle' ? Math.ceil(intialValue/grid[1]) : Math.ceil((grid[1]/2)/grid[1]);+ const x = 19.5%grid[0];+ const y = 4.5;+ const dx = x - index%grid[0];+ const dy = y - Math.ceil(index/grid[1]);+ //console.log(dx, dy);+ values.push(Math.sqrt(dx * dx + dy * dy));+ } else {+ values.push(Math.abs(intialValue - index));+ }+ maxValue = Math.max(...values);+ }+ }+ let progress = values[i];+ if (easing) progress = easing(progress / maxValue) * maxValue;+ if (direction === 'reverse') progress = Math.abs(maxValue - progress);+ const spacing = isRange ? (val2 - val1) / maxValue : val1;+ return start + (spacing * progress) + unit;+ }+ }++ const easingVisualizerEl = document.querySelector('.easing-visualizer');+ const fragment = document.createDocumentFragment();+ const numberOfElements = 101;++ for (let i = 0; i < numberOfElements; i++) {+ fragment.appendChild(document.createElement('div'));+ }++ easingVisualizerEl.appendChild(fragment);++ anime({+ targets: '.easing-visualizer div',+ translateY: (() => {+ const keyframes = [];+ for (let ease in anime.penner) {+ keyframes.push({+ value: stagger([0, -400], {easing: ease}),+ delay: stagger(.125)+ });+ };+ keyframes.push({ value: stagger([0, -400], {easing: 'steps(10)'}), delay: stagger(.125) });+ keyframes.push({ value: 0, delay: stagger(.125) });+ return keyframes;+ })(),+ easing: 'easeInOutSine',+ duration: 16000,+ loop: true+ });++</script>+</html>diff --git a/lib/anime.es.js b/lib/anime.es.jsindex 45216b34..66bba183 100644--- a/lib/anime.es.js+++ b/lib/anime.es.js@@ -278,7 +278,7 @@ var penner = (function () {};var loop = function ( coords ) {- curves[coords].forEach(function (ease, i) {+ curves[coords].forEach(function (ease, i) {eases['ease'+coords+names[i]] = ease;});};@@ -1206,6 +1206,49 @@ function removeTargets(targets) {}}+// Stagger helpers++function stagger(val, params) {+ if ( params === void 0 ) params = {};++ var direction = params.direction || 'normal';+ var easing = params.easing ? parseEasings(params.easing) : null;+ var grid = params.grid;+ var fromIndex = params.from || 0;+ var fromCenter = fromIndex === 'center';+ var fromLast = fromIndex === 'last';+ var isRange = is.arr(val);+ var val1 = isRange ? parseFloat(val[0]) : parseFloat(val);+ var val2 = isRange ? parseFloat(val[1]) : 0;+ var unit = getUnit(isRange ? val[1] : val) || 0;+ var start = params.start || 0 + (isRange ? val1 : 0);+ var values = [];+ var maxValue = 0;+ return function (el, i, t) {+ if (fromCenter) { fromIndex = (t - 1) / 2; }+ if (fromLast) { fromIndex = t - 1; }+ if (!values.length) {+ for (var index = 0; index < t; index++) {+ if (!grid) {+ values.push(Math.abs(fromIndex - index));+ } else {+ var x = !fromCenter ? fromIndex%grid[0] : (grid[0]-1)/2;+ var y = !fromCenter ? Math.floor(fromIndex/grid[1]) : (grid[1]-1)/2;+ var dx = x - index%grid[0];+ var dy = y - Math.floor(index/grid[1]);+ values.push(Math.sqrt(dx * dx + dy * dy));+ }+ maxValue = Math.max.apply(Math, values);+ }+ }+ var progress = values[i];+ if (easing) { progress = easing(progress / maxValue) * maxValue; }+ if (direction === 'reverse') { progress = Math.abs(maxValue - progress); }+ var spacing = isRange ? (val2 - val1) / maxValue : val1;+ return start + (spacing * progress) + unit;+ }+}+// Timelinefunction timeline(params) {@@ -1250,8 +1293,10 @@ anime.setValue = setTargetValue;anime.convertPx = convertPxToUnit;anime.path = getPath;anime.setDashoffset = setDashoffset;+anime.stagger = stagger;anime.timeline = timeline;anime.easing = parseEasings;+anime.penner = penner;anime.random = function (min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; };export default anime;diff --git a/lib/anime.js b/lib/anime.jsindex fa08196e..e5a6d0d7 100644--- a/lib/anime.js+++ b/lib/anime.js@@ -280,7 +280,7 @@ var penner = (function () {};var loop = function ( coords ) {- curves[coords].forEach(function (ease, i) {+ curves[coords].forEach(function (ease, i) {eases['ease'+coords+names[i]] = ease;});};@@ -1208,6 +1208,49 @@ function removeTargets(targets) {}}+// Stagger helpers++function stagger(val, params) {+ if ( params === void 0 ) params = {};++ var direction = params.direction || 'normal';+ var easing = params.easing ? parseEasings(params.easing) : null;+ var grid = params.grid;+ var fromIndex = params.from || 0;+ var fromCenter = fromIndex === 'center';+ var fromLast = fromIndex === 'last';+ var isRange = is.arr(val);+ var val1 = isRange ? parseFloat(val[0]) : parseFloat(val);+ var val2 = isRange ? parseFloat(val[1]) : 0;+ var unit = getUnit(isRange ? val[1] : val) || 0;+ var start = params.start || 0 + (isRange ? val1 : 0);+ var values = [];+ var maxValue = 0;+ return function (el, i, t) {+ if (fromCenter) { fromIndex = (t - 1) / 2; }+ if (fromLast) { fromIndex = t - 1; }+ if (!values.length) {+ for (var index = 0; index < t; index++) {+ if (!grid) {+ values.push(Math.abs(fromIndex - index));+ } else {+ var x = !fromCenter ? fromIndex%grid[0] : (grid[0]-1)/2;+ var y = !fromCenter ? Math.floor(fromIndex/grid[1]) : (grid[1]-1)/2;+ var dx = x - index%grid[0];+ var dy = y - Math.floor(index/grid[1]);+ values.push(Math.sqrt(dx * dx + dy * dy));+ }+ maxValue = Math.max.apply(Math, values);+ }+ }+ var progress = values[i];+ if (easing) { progress = easing(progress / maxValue) * maxValue; }+ if (direction === 'reverse') { progress = Math.abs(maxValue - progress); }+ var spacing = isRange ? (val2 - val1) / maxValue : val1;+ return start + (spacing * progress) + unit;+ }+}+// Timelinefunction timeline(params) {@@ -1252,8 +1295,10 @@ anime.setValue = setTargetValue;anime.convertPx = convertPxToUnit;anime.path = getPath;anime.setDashoffset = setDashoffset;+anime.stagger = stagger;anime.timeline = timeline;anime.easing = parseEasings;+anime.penner = penner;anime.random = function (min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; };module.exports = anime;diff --git a/lib/anime.min.js b/lib/anime.min.jsindex 0f57fde7..d584f7b3 100644--- a/lib/anime.min.js+++ b/lib/anime.min.js@@ -5,4 +5,4 @@* animejs.com*/-!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.anime=n()}(this,function(){"use strict";var e={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,startTime:0,timelineOffset:0},n={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},t=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective"],r={CSS:{},springs:{}};function a(e,n,t){return Math.min(Math.max(e,n),t)}function i(e,n){return e.indexOf(n)>-1}function u(e,n){return e.apply(null,n)}var o={arr:function(e){return Array.isArray(e)},obj:function(e){return i(Object.prototype.toString.call(e),"Object")},pth:function(e){return o.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},dom:function(e){return e.nodeType||o.svg(e)},str:function(e){return"string"==typeof e},fnc:function(e){return"function"==typeof e},und:function(e){return void 0===e},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return o.hex(e)||o.rgb(e)||o.hsl(e)}};function s(e){var n=/\(([^)]+)\)/.exec(e);return n?n[1].split(",").map(function(e){return parseFloat(e)}):[]}function c(e,n){var t=s(e),i=a(o.und(t[0])?1:t[0],.1,100),u=a(o.und(t[1])?100:t[1],.1,100),c=a(o.und(t[2])?10:t[2],.1,100),f=a(o.und(t[3])?0:t[3],.1,100),l=Math.sqrt(u/i),d=c/(2*Math.sqrt(u*i)),p=d<1?l*Math.sqrt(1-d*d):0,v=1,h=d<1?(d*l-f)/p:-f+l;function g(e){var t=n?n*e/1e3:e;return t=d<1?Math.exp(-t*d*l)*(v*Math.cos(p*t)+h*Math.sin(p*t)):(v+h*t)*Math.exp(-t*l),0===e||1===e?e:1-t}return n?g:function(){var n=r.springs[e];if(n)return n;for(var t=0,a=0;;)if(1===g(t+=1/6)){if(++a>=16)break}else a=0;var i=t*(1/6)*1e3;return r.springs[e]=i,i}}function f(e,n){void 0===e&&(e=1),void 0===n&&(n=.5);var t=a(e,1,10),r=a(n,.1,2);return function(e){return 0===e||1===e?e:-t*Math.pow(2,10*(e-1))*Math.sin((e-1-r/(2*Math.PI)*Math.asin(1/t))*(2*Math.PI)/r)}}function l(e){return void 0===e&&(e=10),function(n){return Math.round(n*e)*(1/e)}}var d=function(){var e=11,n=1/(e-1);function t(e,n){return 1-3*n+3*e}function r(e,n){return 3*n-6*e}function a(e){return 3*e}function i(e,n,i){return((t(n,i)*e+r(n,i))*e+a(n))*e}function u(e,n,i){return 3*t(n,i)*e*e+2*r(n,i)*e+a(n)}return function(t,r,a,o){if(0<=t&&t<=1&&0<=a&&a<=1){var s=new Float32Array(e);if(t!==r||a!==o)for(var c=0;c<e;++c)s[c]=i(c*n,t,a);return function(e){return t===r&&a===o?e:0===e||1===e?e:i(f(e),r,o)}}function f(r){for(var o=0,c=1,f=e-1;c!==f&&s[c]<=r;++c)o+=n;var l=o+(r-s[--c])/(s[c+1]-s[c])*n,d=u(l,t,a);return d>=.001?function(e,n,t,r){for(var a=0;a<4;++a){var o=u(n,t,r);if(0===o)return n;n-=(i(n,t,r)-e)/o}return n}(r,l,t,a):0===d?l:function(e,n,t,r,a){for(var u,o,s=0;(u=i(o=n+(t-n)/2,r,a)-e)>0?t=o:n=o,Math.abs(u)>1e-7&&++s<10;);return o}(r,o,o+n,t,a)}}}(),p=function(){var e=["Quad","Cubic","Quart","Quint","Sine","Expo","Circ","Back","Elastic"],n={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],f],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(e,n){return function(t){return 1-f(e,n)(1-t)}}],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(e,n){return function(t){return t<.5?f(e,n)(2*t)/2:1-f(e,n)(-2*t+2)/2}}]},t={linear:[.25,.25,.75,.75]},r=function(r){n[r].forEach(function(n,a){t["ease"+r+e[a]]=n})};for(var a in n)r(a);return t}();function v(e,n){if(o.fnc(e))return e;var t=e.split("(")[0],r=p[t],a=s(e);switch(t){case"spring":return c(e,n);case"cubicBezier":return u(d,a);case"steps":return u(l,a);default:return o.fnc(r)?u(r,a):u(d,r)}}function h(e){try{return document.querySelectorAll(e)}catch(e){return}}function g(e,n){for(var t=e.length,r=arguments.length>=2?arguments[1]:void 0,a=[],i=0;i<t;i++)if(i in e){var u=e[i];n.call(r,u,i,e)&&a.push(u)}return a}function m(e){return e.reduce(function(e,n){return e.concat(o.arr(n)?m(n):n)},[])}function y(e){return o.arr(e)?e:(o.str(e)&&(e=h(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function b(e,n){return e.some(function(e){return e===n})}function x(e){var n={};for(var t in e)n[t]=e[t];return n}function w(e,n){var t=x(e);for(var r in e)t[r]=n.hasOwnProperty(r)?n[r]:e[r];return t}function M(e,n){var t=x(e);for(var r in n)t[r]=o.und(e[r])?n[r]:e[r];return t}function C(e){return o.rgb(e)?(t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(n=e))?"rgba("+t[1]+",1)":n:o.hex(e)?(r=e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(e,n,t,r){return n+n+t+t+r+r}),a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r),"rgba("+parseInt(a[1],16)+","+parseInt(a[2],16)+","+parseInt(a[3],16)+",1)"):o.hsl(e)?function(e){var n,t,r,a=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(e),i=parseInt(a[1],10)/360,u=parseInt(a[2],10)/100,o=parseInt(a[3],10)/100,s=a[4]||1;function c(e,n,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?e+6*(n-e)*t:t<.5?n:t<2/3?e+(n-e)*(2/3-t)*6:e}if(0==u)n=t=r=o;else{var f=o<.5?o*(1+u):o+u-o*u,l=2*o-f;n=c(l,f,i+1/3),t=c(l,f,i),r=c(l,f,i-1/3)}return"rgba("+255*n+","+255*t+","+255*r+","+s+")"}(e):void 0;var n,t,r,a}function O(e){var n=/([\+\-]?[0-9#\.]+)(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(n)return n[2]}function k(e,n){return o.fnc(e)?e(n.target,n.id,n.total):e}function T(e,n){return e.getAttribute(n)}function I(e,n,t){if(b([t,"deg","rad","turn"],O(n)))return n;var a=r.CSS[n+t];if(!o.und(a))return a;var i=document.createElement(e.tagName),u=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;u.appendChild(i),i.style.position="absolute",i.style.width=100+t;var s=100/i.offsetWidth;u.removeChild(i);var c=s*parseFloat(n);return r.CSS[n+t]=c,c}function B(e,n,t){if(n in e.style){var r=n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),a=e.style[n]||getComputedStyle(e).getPropertyValue(r)||"0";return t?I(e,a,t):a}}function D(e,n){return o.dom(e)&&(T(e,n)||o.svg(e)&&e[n])?"attribute":o.dom(e)&&b(t,n)?"transform":o.dom(e)&&"transform"!==n&&B(e,n)?"css":null!=e[n]?"object":void 0}function P(e){if(o.dom(e)){for(var n,t=e.style.transform||"",r=/(\w+)\(([^)]*)\)/g,a=new Map;n=r.exec(t);)a.set(n[1],n[2]);return a}}function A(e,n,t,r){var a,u=i(n,"scale")?1:0+(i(a=n,"translate")||"perspective"===a?"px":i(a,"rotate")||i(a,"skew")?"deg":void 0),o=P(e).get(n)||u;return t.transforms.list.set(n,o),t.transforms.last=n,r?I(e,o,r):o}function N(e,n,t,r){switch(D(e,n)){case"transform":return A(e,n,r,t);case"css":return B(e,n,t);case"attribute":return T(e,n);default:return e[n]||0}}function E(e,n){var t=/^(\*=|\+=|-=)/.exec(e);if(!t)return e;var r=O(e)||0,a=parseFloat(n),i=parseFloat(e.replace(t[0],""));switch(t[0][0]){case"+":return a+i+r;case"-":return a-i+r;case"*":return a*i+r}}function S(e,n){if(o.col(e))return C(e);var t=O(e),r=t?e.substr(0,e.length-t.length):e;return n&&!/\s/g.test(e)?r+n:r}function F(e,n){return Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2))}function L(e){for(var n,t=e.points,r=0,a=0;a<t.numberOfItems;a++){var i=t.getItem(a);a>0&&(r+=F(n,i)),n=i}return r}function j(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return i=e,2*Math.PI*T(i,"r");case"rect":return 2*T(a=e,"width")+2*T(a,"height");case"line":return F({x:T(r=e,"x1"),y:T(r,"y1")},{x:T(r,"x2"),y:T(r,"y2")});case"polyline":return L(e);case"polygon":return t=(n=e).points,L(n)+F(t.getItem(t.numberOfItems-1),t.getItem(0))}var n,t,r,a,i}function $(e,n){var t=n||{},r=t.el||function(e){for(var n=e.parentNode;o.svg(n)&&(n=n.parentNode,o.svg(n.parentNode)););return n}(e),a=r.getBoundingClientRect(),i=r.getAttribute("viewBox"),u=a.width,s=a.height,c=t.viewBox||(i?i.split(" "):[0,0,u,s]);return{el:r,viewBox:c,x:c[0]/1,y:c[1]/1,w:u/c[2],h:s/c[3]}}function q(e,n){function t(t){void 0===t&&(t=0);var r=n+t>=1?n+t:0;return e.el.getPointAtLength(r)}var r=$(e.el,e.svg),a=t(),i=t(-1),u=t(1);switch(e.property){case"x":return(a.x-r.x)*r.w;case"y":return(a.y-r.y)*r.h;case"angle":return 180*Math.atan2(u.y-i.y,u.x-i.x)/Math.PI}}function V(e,n){var t=/-?\d*\.?\d+/g,r=S(o.pth(e)?e.totalLength:e,n)+"";return{original:r,numbers:r.match(t)?r.match(t).map(Number):[0],strings:o.str(e)||n?r.split(t):[]}}function X(e){return g(e?m(o.arr(e)?e.map(y):y(e)):[],function(e,n,t){return t.indexOf(e)===n})}function Y(e){var n=X(e);return n.map(function(e,t){return{target:e,id:t,total:n.length,transforms:{list:P(e)}}})}function Z(e,n){var t=x(n);if(/^spring/.test(t.easing)&&(t.duration=c(t.easing)),o.arr(e)){var r=e.length;2===r&&!o.obj(e[0])?e={value:e}:o.fnc(n.duration)||(t.duration=n.duration/r)}var a=o.arr(e)?e:[e];return a.map(function(e,t){var r=o.obj(e)&&!o.pth(e)?e:{value:e};return o.und(r.delay)&&(r.delay=t?0:n.delay),o.und(r.endDelay)&&(r.endDelay=t===a.length-1?n.endDelay:0),r}).map(function(e){return M(e,t)})}function Q(e,n){var t;return e.tweens.map(function(r){var a=function(e,n){var t={};for(var r in e){var a=k(e[r],n);o.arr(a)&&1===(a=a.map(function(e){return k(e,n)})).length&&(a=a[0]),t[r]=a}return t.duration=parseFloat(t.duration),t.delay=parseFloat(t.delay),t}(r,n),i=a.value,u=o.arr(i)?i[1]:i,s=O(u),c=N(n.target,e.name,s,n),f=t?t.to.original:c,l=o.arr(i)?i[0]:f,d=O(l)||O(c),p=s||d;return a.from=V(l,p),a.to=V(E(u,l),p),a.start=t?t.end:0,a.end=a.start+a.delay+a.duration+a.endDelay,a.easing=v(a.easing,a.duration),a.isPath=o.pth(i),a.isColor=o.col(a.from.original),a.isColor&&(a.round=1),t=a,a})}var z={css:function(e,n,t){return e.style[n]=t},attribute:function(e,n,t){return e.setAttribute(n,t)},object:function(e,n,t){return e[n]=t},transform:function(e,n,t,r,a){if(r.list.set(n,t),n===r.last||a){var i="";r.list.forEach(function(e,n){i+=n+"("+e+") "}),e.style.transform=i}}};function G(e,n){return g(m(e.map(function(e){return n.map(function(n){return function(e,n){var t=D(e.target,n.name);if(t){var r=Q(n,e),a=r[r.length-1];return{type:t,property:n.name,animatable:e,tweens:r,duration:a.end,delay:r[0].delay,endDelay:a.endDelay}}}(e,n)})})),function(e){return!o.und(e)})}function H(e,n,t){var r=e.length,a=function(e){return e.timelineOffset?e.timelineOffset:0},i={};return i.duration=r?Math.max.apply(Math,e.map(function(e){return a(e)+e.duration})):n.duration,i.delay=r?Math.min.apply(Math,e.map(function(e){return a(e)+e.delay})):n.delay,i.endDelay=r?i.duration-Math.max.apply(Math,e.map(function(e){return a(e)+e.duration-e.endDelay})):n.endDelay,i}var R=0;function W(t){var r=w(e,t),a=w(n,t),i=Y(t.targets),u=G(i,function(e,n,t){var r=[];for(var a in t)e.hasOwnProperty(a)||n.hasOwnProperty(a)||"targets"===a||"states"===a||r.push({name:a,tweens:Z(t[a],n)});return r}(r,a,t)),o=H(u,a),s=R;return R++,M(r,{id:s,children:[],states:function(e){var n=e.states;if(n){var t=x(e);delete t.states;var r={default:t};for(var a in n){r[a]=x(t);var i=n[a];for(var u in i)r[a][u]=i[u]}return r}}(t),currentState:null,animatables:i,animations:u,duration:o.duration,delay:o.delay,endDelay:o.endDelay})}var J,K=[],U=[],_=function(){function e(){J=requestAnimationFrame(n)}function n(n){var t=K.length;if(t){for(var r=0;r<t;){var a=K[r];if(a.paused){var i=K.indexOf(a);i>-1&&(K.splice(i,1),t=K.length)}else a.tick(n);r++}e()}else J=cancelAnimationFrame(J)}return e}();function ee(e){void 0===e&&(e={});var n,t=0,r=0,i=0,u=0,o=null;function s(){return window.Promise&&new Promise(function(e){return o=e})}var c=s(),f=W(e);function l(){f.reversed=!f.reversed,n.forEach(function(e){return e.reversed=f.reversed})}function d(e){return f.reversed?f.duration-e:e}function p(){t=0,r=d(f.currentTime)*(1/ee.speed)}function v(e){for(var n=0,t=f.animations,r=t.length;n<r;){var i=t[n],u=i.animatable,o=i.tweens,s=o.length-1,c=o[s];s&&(c=g(o,function(n){return e<n.end})[0]||c);for(var l=a(e-c.start-c.delay,0,c.duration)/c.duration,d=isNaN(l)?1:c.easing(l),p=c.to.strings,v=c.round,h=[],m=c.to.numbers.length,y=void 0,b=0;b<m;b++){var x=void 0,w=c.to.numbers[b],M=c.from.numbers[b]||0;x=c.isPath?q(c.value,d*w):M+d*(w-M),v&&(c.isColor&&b>2||(x=Math.round(x*v)/v)),h.push(x)}var C=p.length;if(C){y=p[0];for(var O=0;O<C;O++){p[O];var k=p[O+1],T=h[O];isNaN(T)||(y+=k?T+k:T+" ")}}else y=h[0];z[i.type](u.target,i.property,y,u.transforms),i.currentValue=y,n++}}function h(e){f[e]&&!f.passthrough&&f[e](f)}function m(e){var p=f.duration,g=f.delay,m=p-f.endDelay,y=f.reversed,b=d(e);f.progress=a(b/p*100,0,100),f.began||(f.began=!0,h("begin"),h("loopBegin")),(!f.changeBegan&&!y&&b>=g&&b<=m||!f.changeBegan&&y&&b<=m&&b>=g)&&(f.changeBegan=!0,f.changeCompleted=!1,h("changeBegin")),b>=g&&b<=m&&h("change"),(!f.changeCompleted&&!y&&b>=m||!f.changeCompleted&&y&&b<=g)&&(f.changeCompleted=!0,f.changeBegan=!1,h("changeComplete")),n&&function(e){if(f.seeked&&e<f.currentTime)for(var t=u;t--;){var r=n[t];r.seek(e-r.timelineOffset)}else for(var a=0;a<u;a++){var i=n[a];i.seek(e-i.timelineOffset)}}(b),b>=g&&b<=p?v(b):(b<=g&&0!==f.currentTime&&v(0),(b>=p&&f.currentTime!==p||!p)&&v(p)),f.currentTime=a(b,0,p),h("update"),e>=p&&(r=0,h("loopComplete"),f.remaining&&!0!==f.remaining&&f.remaining--,f.remaining?(t=i,h("loopBegin"),"alternate"===f.direction&&l()):(f.paused=!0,f.completed||(f.completed=!0,h("complete"),"Promise"in window&&(o(),c=s()))))}return f.reset=function(){var e=f.direction,t=f.loop;f.passthrough=!1,f.currentTime=0,f.progress=0,f.paused=!0,f.began=!1,f.changeBegan=!1,f.changeCompleted=!1,f.completed=!1,f.seeked=!1,f.reversed="reverse"===e,f.remaining="alternate"===e&&1===t?2:t,n=f.children;for(var r=u=n.length;r--;)f.children[r].reset();v(0)},f.tick=function(e){i=e,t||(t=i),f.seeked=!1,m((i+(r-t))*ee.speed)},f.seek=function(e){f.seeked=!0,m(d(e))},f.pause=function(){f.paused=!0,p()},f.play=function(){f.paused&&(f.paused=!1,f.seeked&&p(),K.push(f),J||_())},f.reverse=function(){l(),p()},f.restart=function(){f.reset(),p(),f.play()},f.animateTo=function(e,n){var t=f.states[e];if(t){n&&(t=M(n,t)),f.pause();var r=ee(t);return r.currentState=e,r}},f.goTo=function(e,n){var t=f.animateTo(e,n);return t.seek(t.duration),t},f.finished=c,f.reset(),f.startTime&&(m(f.startTime-f.duration*Math.floor(f.startTime/f.duration)),p()),f.states&&f.goTo("default"),f.autoplay&&!f.states&&f.play(),f}function ne(e,n){for(var t=n.length;t--;)b(e,n[t].animatable.target)&&n.splice(t,1)}return document.addEventListener("visibilitychange",function(){document.hidden?(K.forEach(function(e){return e.pause()}),U=K.slice(0),K=[]):U.forEach(function(e){return e.play()})}),ee.version="3.0.0",ee.speed=1,ee.running=K,ee.remove=function(e){for(var n=X(e),t=K.length;t--;){var r=K[t],a=r.animations,i=r.children;ne(n,a);for(var u=i.length;u--;){var o=i[u],s=o.animations;ne(n,s),s.length||o.children.length||i.splice(u,1)}a.length||i.length||r.pause()}},ee.getValue=N,ee.setValue=function(e,n){Y(e).forEach(function(e){for(var t in n){var r=k(n[t],e),a=e.target,i=O(r),u=N(a,t,i,e),o=E(S(r,i||O(u)),u),s=D(a,t);z[s](a,t,o,e.transforms,!0)}})},ee.convertPx=I,ee.path=function(e,n){var t=o.str(e)?h(e)[0]:e,r=n||100;return function(e){return{property:e,el:t,svg:$(t),totalLength:j(t)*(r/100)}}},ee.setDashoffset=function(e){var n=j(e);return e.setAttribute("stroke-dasharray",n),n},ee.timeline=function(e){void 0===e&&(e={});var t=ee(e);return t.duration=0,t.add=function(r,a){var i=K.indexOf(t);function u(e){e.passthrough=!0}i>-1&&K.splice(i,1),t.children.forEach(u);var s=M(r,w(n,e));s.targets=s.targets||e.targets;var c=t.duration;s.autoplay=!1,s.direction=t.direction,s.timelineOffset=o.und(a)?c:E(a,c),u(t),t.seek(s.timelineOffset);var f=ee(s);u(f),t.children.push(f);var l=H(t.children,e);return t.delay=l.delay,t.endDelay=l.endDelay,t.duration=l.duration,t.seek(0),t.reset(),t.autoplay&&t.play(),t},t},ee.easing=v,ee.random=function(e,n){return Math.floor(Math.random()*(n-e+1))+e},ee});\ No newline at end of file+!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.anime=n()}(this,function(){"use strict";var e={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,startTime:0,timelineOffset:0},n={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},t=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective"],r={CSS:{},springs:{}};function a(e,n,t){return Math.min(Math.max(e,n),t)}function i(e,n){return e.indexOf(n)>-1}function o(e,n){return e.apply(null,n)}var u={arr:function(e){return Array.isArray(e)},obj:function(e){return i(Object.prototype.toString.call(e),"Object")},pth:function(e){return u.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},dom:function(e){return e.nodeType||u.svg(e)},str:function(e){return"string"==typeof e},fnc:function(e){return"function"==typeof e},und:function(e){return void 0===e},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return u.hex(e)||u.rgb(e)||u.hsl(e)}};function s(e){var n=/\(([^)]+)\)/.exec(e);return n?n[1].split(",").map(function(e){return parseFloat(e)}):[]}function c(e,n){var t=s(e),i=a(u.und(t[0])?1:t[0],.1,100),o=a(u.und(t[1])?100:t[1],.1,100),c=a(u.und(t[2])?10:t[2],.1,100),f=a(u.und(t[3])?0:t[3],.1,100),l=Math.sqrt(o/i),d=c/(2*Math.sqrt(o*i)),p=d<1?l*Math.sqrt(1-d*d):0,v=1,h=d<1?(d*l-f)/p:-f+l;function g(e){var t=n?n*e/1e3:e;return t=d<1?Math.exp(-t*d*l)*(v*Math.cos(p*t)+h*Math.sin(p*t)):(v+h*t)*Math.exp(-t*l),0===e||1===e?e:1-t}return n?g:function(){var n=r.springs[e];if(n)return n;for(var t=0,a=0;;)if(1===g(t+=1/6)){if(++a>=16)break}else a=0;var i=t*(1/6)*1e3;return r.springs[e]=i,i}}function f(e,n){void 0===e&&(e=1),void 0===n&&(n=.5);var t=a(e,1,10),r=a(n,.1,2);return function(e){return 0===e||1===e?e:-t*Math.pow(2,10*(e-1))*Math.sin((e-1-r/(2*Math.PI)*Math.asin(1/t))*(2*Math.PI)/r)}}function l(e){return void 0===e&&(e=10),function(n){return Math.round(n*e)*(1/e)}}var d=function(){var e=11,n=1/(e-1);function t(e,n){return 1-3*n+3*e}function r(e,n){return 3*n-6*e}function a(e){return 3*e}function i(e,n,i){return((t(n,i)*e+r(n,i))*e+a(n))*e}function o(e,n,i){return 3*t(n,i)*e*e+2*r(n,i)*e+a(n)}return function(t,r,a,u){if(0<=t&&t<=1&&0<=a&&a<=1){var s=new Float32Array(e);if(t!==r||a!==u)for(var c=0;c<e;++c)s[c]=i(c*n,t,a);return function(e){return t===r&&a===u?e:0===e||1===e?e:i(f(e),r,u)}}function f(r){for(var u=0,c=1,f=e-1;c!==f&&s[c]<=r;++c)u+=n;var l=u+(r-s[--c])/(s[c+1]-s[c])*n,d=o(l,t,a);return d>=.001?function(e,n,t,r){for(var a=0;a<4;++a){var u=o(n,t,r);if(0===u)return n;n-=(i(n,t,r)-e)/u}return n}(r,l,t,a):0===d?l:function(e,n,t,r,a){for(var o,u,s=0;(o=i(u=n+(t-n)/2,r,a)-e)>0?t=u:n=u,Math.abs(o)>1e-7&&++s<10;);return u}(r,u,u+n,t,a)}}}(),p=function(){var e=["Quad","Cubic","Quart","Quint","Sine","Expo","Circ","Back","Elastic"],n={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],f],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(e,n){return function(t){return 1-f(e,n)(1-t)}}],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(e,n){return function(t){return t<.5?f(e,n)(2*t)/2:1-f(e,n)(-2*t+2)/2}}]},t={linear:[.25,.25,.75,.75]},r=function(r){n[r].forEach(function(n,a){t["ease"+r+e[a]]=n})};for(var a in n)r(a);return t}();function v(e,n){if(u.fnc(e))return e;var t=e.split("(")[0],r=p[t],a=s(e);switch(t){case"spring":return c(e,n);case"cubicBezier":return o(d,a);case"steps":return o(l,a);default:return u.fnc(r)?o(r,a):o(d,r)}}function h(e){try{return document.querySelectorAll(e)}catch(e){return}}function g(e,n){for(var t=e.length,r=arguments.length>=2?arguments[1]:void 0,a=[],i=0;i<t;i++)if(i in e){var o=e[i];n.call(r,o,i,e)&&a.push(o)}return a}function m(e){return e.reduce(function(e,n){return e.concat(u.arr(n)?m(n):n)},[])}function y(e){return u.arr(e)?e:(u.str(e)&&(e=h(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function b(e,n){return e.some(function(e){return e===n})}function x(e){var n={};for(var t in e)n[t]=e[t];return n}function M(e,n){var t=x(e);for(var r in e)t[r]=n.hasOwnProperty(r)?n[r]:e[r];return t}function w(e,n){var t=x(e);for(var r in n)t[r]=u.und(e[r])?n[r]:e[r];return t}function C(e){return u.rgb(e)?(t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(n=e))?"rgba("+t[1]+",1)":n:u.hex(e)?(r=e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(e,n,t,r){return n+n+t+t+r+r}),a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r),"rgba("+parseInt(a[1],16)+","+parseInt(a[2],16)+","+parseInt(a[3],16)+",1)"):u.hsl(e)?function(e){var n,t,r,a=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(e),i=parseInt(a[1],10)/360,o=parseInt(a[2],10)/100,u=parseInt(a[3],10)/100,s=a[4]||1;function c(e,n,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?e+6*(n-e)*t:t<.5?n:t<2/3?e+(n-e)*(2/3-t)*6:e}if(0==o)n=t=r=u;else{var f=u<.5?u*(1+o):u+o-u*o,l=2*u-f;n=c(l,f,i+1/3),t=c(l,f,i),r=c(l,f,i-1/3)}return"rgba("+255*n+","+255*t+","+255*r+","+s+")"}(e):void 0;var n,t,r,a}function O(e){var n=/([\+\-]?[0-9#\.]+)(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(n)return n[2]}function k(e,n){return u.fnc(e)?e(n.target,n.id,n.total):e}function T(e,n){return e.getAttribute(n)}function I(e,n,t){if(b([t,"deg","rad","turn"],O(n)))return n;var a=r.CSS[n+t];if(!u.und(a))return a;var i=document.createElement(e.tagName),o=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;o.appendChild(i),i.style.position="absolute",i.style.width=100+t;var s=100/i.offsetWidth;o.removeChild(i);var c=s*parseFloat(n);return r.CSS[n+t]=c,c}function B(e,n,t){if(n in e.style){var r=n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),a=e.style[n]||getComputedStyle(e).getPropertyValue(r)||"0";return t?I(e,a,t):a}}function D(e,n){return u.dom(e)&&(T(e,n)||u.svg(e)&&e[n])?"attribute":u.dom(e)&&b(t,n)?"transform":u.dom(e)&&"transform"!==n&&B(e,n)?"css":null!=e[n]?"object":void 0}function P(e){if(u.dom(e)){for(var n,t=e.style.transform||"",r=/(\w+)\(([^)]*)\)/g,a=new Map;n=r.exec(t);)a.set(n[1],n[2]);return a}}function A(e,n,t,r){var a,o=i(n,"scale")?1:0+(i(a=n,"translate")||"perspective"===a?"px":i(a,"rotate")||i(a,"skew")?"deg":void 0),u=P(e).get(n)||o;return t.transforms.list.set(n,u),t.transforms.last=n,r?I(e,u,r):u}function F(e,n,t,r){switch(D(e,n)){case"transform":return A(e,n,r,t);case"css":return B(e,n,t);case"attribute":return T(e,n);default:return e[n]||0}}function N(e,n){var t=/^(\*=|\+=|-=)/.exec(e);if(!t)return e;var r=O(e)||0,a=parseFloat(n),i=parseFloat(e.replace(t[0],""));switch(t[0][0]){case"+":return a+i+r;case"-":return a-i+r;case"*":return a*i+r}}function E(e,n){if(u.col(e))return C(e);var t=O(e),r=t?e.substr(0,e.length-t.length):e;return n&&!/\s/g.test(e)?r+n:r}function S(e,n){return Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2))}function L(e){for(var n,t=e.points,r=0,a=0;a<t.numberOfItems;a++){var i=t.getItem(a);a>0&&(r+=S(n,i)),n=i}return r}function j(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return i=e,2*Math.PI*T(i,"r");case"rect":return 2*T(a=e,"width")+2*T(a,"height");case"line":return S({x:T(r=e,"x1"),y:T(r,"y1")},{x:T(r,"x2"),y:T(r,"y2")});case"polyline":return L(e);case"polygon":return t=(n=e).points,L(n)+S(t.getItem(t.numberOfItems-1),t.getItem(0))}var n,t,r,a,i}function q(e,n){var t=n||{},r=t.el||function(e){for(var n=e.parentNode;u.svg(n)&&(n=n.parentNode,u.svg(n.parentNode)););return n}(e),a=r.getBoundingClientRect(),i=r.getAttribute("viewBox"),o=a.width,s=a.height,c=t.viewBox||(i?i.split(" "):[0,0,o,s]);return{el:r,viewBox:c,x:c[0]/1,y:c[1]/1,w:o/c[2],h:s/c[3]}}function $(e,n){function t(t){void 0===t&&(t=0);var r=n+t>=1?n+t:0;return e.el.getPointAtLength(r)}var r=q(e.el,e.svg),a=t(),i=t(-1),o=t(1);switch(e.property){case"x":return(a.x-r.x)*r.w;case"y":return(a.y-r.y)*r.h;case"angle":return 180*Math.atan2(o.y-i.y,o.x-i.x)/Math.PI}}function V(e,n){var t=/-?\d*\.?\d+/g,r=E(u.pth(e)?e.totalLength:e,n)+"";return{original:r,numbers:r.match(t)?r.match(t).map(Number):[0],strings:u.str(e)||n?r.split(t):[]}}function X(e){return g(e?m(u.arr(e)?e.map(y):y(e)):[],function(e,n,t){return t.indexOf(e)===n})}function Y(e){var n=X(e);return n.map(function(e,t){return{target:e,id:t,total:n.length,transforms:{list:P(e)}}})}function Z(e,n){var t=x(n);if(/^spring/.test(t.easing)&&(t.duration=c(t.easing)),u.arr(e)){var r=e.length;2===r&&!u.obj(e[0])?e={value:e}:u.fnc(n.duration)||(t.duration=n.duration/r)}var a=u.arr(e)?e:[e];return a.map(function(e,t){var r=u.obj(e)&&!u.pth(e)?e:{value:e};return u.und(r.delay)&&(r.delay=t?0:n.delay),u.und(r.endDelay)&&(r.endDelay=t===a.length-1?n.endDelay:0),r}).map(function(e){return w(e,t)})}function Q(e,n){var t;return e.tweens.map(function(r){var a=function(e,n){var t={};for(var r in e){var a=k(e[r],n);u.arr(a)&&1===(a=a.map(function(e){return k(e,n)})).length&&(a=a[0]),t[r]=a}return t.duration=parseFloat(t.duration),t.delay=parseFloat(t.delay),t}(r,n),i=a.value,o=u.arr(i)?i[1]:i,s=O(o),c=F(n.target,e.name,s,n),f=t?t.to.original:c,l=u.arr(i)?i[0]:f,d=O(l)||O(c),p=s||d;return a.from=V(l,p),a.to=V(N(o,l),p),a.start=t?t.end:0,a.end=a.start+a.delay+a.duration+a.endDelay,a.easing=v(a.easing,a.duration),a.isPath=u.pth(i),a.isColor=u.col(a.from.original),a.isColor&&(a.round=1),t=a,a})}var z={css:function(e,n,t){return e.style[n]=t},attribute:function(e,n,t){return e.setAttribute(n,t)},object:function(e,n,t){return e[n]=t},transform:function(e,n,t,r,a){if(r.list.set(n,t),n===r.last||a){var i="";r.list.forEach(function(e,n){i+=n+"("+e+") "}),e.style.transform=i}}};function G(e,n){return g(m(e.map(function(e){return n.map(function(n){return function(e,n){var t=D(e.target,n.name);if(t){var r=Q(n,e),a=r[r.length-1];return{type:t,property:n.name,animatable:e,tweens:r,duration:a.end,delay:r[0].delay,endDelay:a.endDelay}}}(e,n)})})),function(e){return!u.und(e)})}function H(e,n,t){var r=e.length,a=function(e){return e.timelineOffset?e.timelineOffset:0},i={};return i.duration=r?Math.max.apply(Math,e.map(function(e){return a(e)+e.duration})):n.duration,i.delay=r?Math.min.apply(Math,e.map(function(e){return a(e)+e.delay})):n.delay,i.endDelay=r?i.duration-Math.max.apply(Math,e.map(function(e){return a(e)+e.duration-e.endDelay})):n.endDelay,i}var R=0;function W(t){var r=M(e,t),a=M(n,t),i=Y(t.targets),o=G(i,function(e,n,t){var r=[];for(var a in t)e.hasOwnProperty(a)||n.hasOwnProperty(a)||"targets"===a||"states"===a||r.push({name:a,tweens:Z(t[a],n)});return r}(r,a,t)),u=H(o,a),s=R;return R++,w(r,{id:s,children:[],states:function(e){var n=e.states;if(n){var t=x(e);delete t.states;var r={default:t};for(var a in n){r[a]=x(t);var i=n[a];for(var o in i)r[a][o]=i[o]}return r}}(t),currentState:null,animatables:i,animations:o,duration:u.duration,delay:u.delay,endDelay:u.endDelay})}var J,K=[],U=[],_=function(){function e(){J=requestAnimationFrame(n)}function n(n){var t=K.length;if(t){for(var r=0;r<t;){var a=K[r];if(a.paused){var i=K.indexOf(a);i>-1&&(K.splice(i,1),t=K.length)}else a.tick(n);r++}e()}else J=cancelAnimationFrame(J)}return e}();function ee(e){void 0===e&&(e={});var n,t=0,r=0,i=0,o=0,u=null;function s(){return window.Promise&&new Promise(function(e){return u=e})}var c=s(),f=W(e);function l(){f.reversed=!f.reversed,n.forEach(function(e){return e.reversed=f.reversed})}function d(e){return f.reversed?f.duration-e:e}function p(){t=0,r=d(f.currentTime)*(1/ee.speed)}function v(e){for(var n=0,t=f.animations,r=t.length;n<r;){var i=t[n],o=i.animatable,u=i.tweens,s=u.length-1,c=u[s];s&&(c=g(u,function(n){return e<n.end})[0]||c);for(var l=a(e-c.start-c.delay,0,c.duration)/c.duration,d=isNaN(l)?1:c.easing(l),p=c.to.strings,v=c.round,h=[],m=c.to.numbers.length,y=void 0,b=0;b<m;b++){var x=void 0,M=c.to.numbers[b],w=c.from.numbers[b]||0;x=c.isPath?$(c.value,d*M):w+d*(M-w),v&&(c.isColor&&b>2||(x=Math.round(x*v)/v)),h.push(x)}var C=p.length;if(C){y=p[0];for(var O=0;O<C;O++){p[O];var k=p[O+1],T=h[O];isNaN(T)||(y+=k?T+k:T+" ")}}else y=h[0];z[i.type](o.target,i.property,y,o.transforms),i.currentValue=y,n++}}function h(e){f[e]&&!f.passthrough&&f[e](f)}function m(e){var p=f.duration,g=f.delay,m=p-f.endDelay,y=f.reversed,b=d(e);f.progress=a(b/p*100,0,100),f.began||(f.began=!0,h("begin"),h("loopBegin")),(!f.changeBegan&&!y&&b>=g&&b<=m||!f.changeBegan&&y&&b<=m&&b>=g)&&(f.changeBegan=!0,f.changeCompleted=!1,h("changeBegin")),b>=g&&b<=m&&h("change"),(!f.changeCompleted&&!y&&b>=m||!f.changeCompleted&&y&&b<=g)&&(f.changeCompleted=!0,f.changeBegan=!1,h("changeComplete")),n&&function(e){if(f.seeked&&e<f.currentTime)for(var t=o;t--;){var r=n[t];r.seek(e-r.timelineOffset)}else for(var a=0;a<o;a++){var i=n[a];i.seek(e-i.timelineOffset)}}(b),b>=g&&b<=p?v(b):(b<=g&&0!==f.currentTime&&v(0),(b>=p&&f.currentTime!==p||!p)&&v(p)),f.currentTime=a(b,0,p),h("update"),e>=p&&(r=0,h("loopComplete"),f.remaining&&!0!==f.remaining&&f.remaining--,f.remaining?(t=i,h("loopBegin"),"alternate"===f.direction&&l()):(f.paused=!0,f.completed||(f.completed=!0,h("complete"),"Promise"in window&&(u(),c=s()))))}return f.reset=function(){var e=f.direction,t=f.loop;f.passthrough=!1,f.currentTime=0,f.progress=0,f.paused=!0,f.began=!1,f.changeBegan=!1,f.changeCompleted=!1,f.completed=!1,f.seeked=!1,f.reversed="reverse"===e,f.remaining="alternate"===e&&1===t?2:t,n=f.children;for(var r=o=n.length;r--;)f.children[r].reset();v(0)},f.tick=function(e){i=e,t||(t=i),f.seeked=!1,m((i+(r-t))*ee.speed)},f.seek=function(e){f.seeked=!0,m(d(e))},f.pause=function(){f.paused=!0,p()},f.play=function(){f.paused&&(f.paused=!1,f.seeked&&p(),K.push(f),J||_())},f.reverse=function(){l(),p()},f.restart=function(){f.reset(),p(),f.play()},f.animateTo=function(e,n){var t=f.states[e];if(t){n&&(t=w(n,t)),f.pause();var r=ee(t);return r.currentState=e,r}},f.goTo=function(e,n){var t=f.animateTo(e,n);return t.seek(t.duration),t},f.finished=c,f.reset(),f.startTime&&(m(f.startTime-f.duration*Math.floor(f.startTime/f.duration)),p()),f.states&&f.goTo("default"),f.autoplay&&!f.states&&f.play(),f}function ne(e,n){for(var t=n.length;t--;)b(e,n[t].animatable.target)&&n.splice(t,1)}return document.addEventListener("visibilitychange",function(){document.hidden?(K.forEach(function(e){return e.pause()}),U=K.slice(0),K=[]):U.forEach(function(e){return e.play()})}),ee.version="3.0.0",ee.speed=1,ee.running=K,ee.remove=function(e){for(var n=X(e),t=K.length;t--;){var r=K[t],a=r.animations,i=r.children;ne(n,a);for(var o=i.length;o--;){var u=i[o],s=u.animations;ne(n,s),s.length||u.children.length||i.splice(o,1)}a.length||i.length||r.pause()}},ee.getValue=F,ee.setValue=function(e,n){Y(e).forEach(function(e){for(var t in n){var r=k(n[t],e),a=e.target,i=O(r),o=F(a,t,i,e),u=N(E(r,i||O(o)),o),s=D(a,t);z[s](a,t,u,e.transforms,!0)}})},ee.convertPx=I,ee.path=function(e,n){var t=u.str(e)?h(e)[0]:e,r=n||100;return function(e){return{property:e,el:t,svg:q(t),totalLength:j(t)*(r/100)}}},ee.setDashoffset=function(e){var n=j(e);return e.setAttribute("stroke-dasharray",n),n},ee.stagger=function(e,n){void 0===n&&(n={});var t=n.direction||"normal",r=n.easing?v(n.easing):null,a=n.grid,i=n.from||0,o="center"===i,s="last"===i,c=u.arr(e),f=c?parseFloat(e[0]):parseFloat(e),l=c?parseFloat(e[1]):0,d=O(c?e[1]:e)||0,p=n.start||0+(c?f:0),h=[],g=0;return function(e,n,u){if(o&&(i=(u-1)/2),s&&(i=u-1),!h.length)for(var v=0;v<u;v++){if(a){var m=o?(a[0]-1)/2:i%a[0],y=o?(a[1]-1)/2:Math.floor(i/a[1]),b=m-v%a[0],x=y-Math.floor(v/a[1]);h.push(Math.sqrt(b*b+x*x))}else h.push(Math.abs(i-v));g=Math.max.apply(Math,h)}var M=h[n];return r&&(M=r(M/g)*g),"reverse"===t&&(M=Math.abs(g-M)),p+(c?(l-f)/g:f)*M+d}},ee.timeline=function(e){void 0===e&&(e={});var t=ee(e);return t.duration=0,t.add=function(r,a){var i=K.indexOf(t);function o(e){e.passthrough=!0}i>-1&&K.splice(i,1),t.children.forEach(o);var s=w(r,M(n,e));s.targets=s.targets||e.targets;var c=t.duration;s.autoplay=!1,s.direction=t.direction,s.timelineOffset=u.und(a)?c:N(a,c),o(t),t.seek(s.timelineOffset);var f=ee(s);o(f),t.children.push(f);var l=H(t.children,e);return t.delay=l.delay,t.endDelay=l.endDelay,t.duration=l.duration,t.seek(0),t.reset(),t.autoplay&&t.play(),t},t},ee.easing=v,ee.penner=p,ee.random=function(e,n){return Math.floor(Math.random()*(n-e+1))+e},ee});\ No newline at end of filediff --git a/src/index.js b/src/index.jsindex 41f84346..6ed15662 100644--- a/src/index.js+++ b/src/index.js@@ -266,7 +266,7 @@ const penner = (() => {}for (let coords in curves) {- curves[coords].forEach((ease, i) => {+ curves[coords].forEach((ease, i) => {eases['ease'+coords+names[i]] = ease;});}@@ -1188,6 +1188,48 @@ function removeTargets(targets) {}}+// Stagger helpers++function stagger(val, params = {}) {+ const direction = params.direction || 'normal';+ const easing = params.easing ? parseEasings(params.easing) : null;+ const grid = params.grid;+ let fromIndex = params.from || 0;+ const fromCenter = fromIndex === 'center';+ const fromLast = fromIndex === 'last';+ const isRange = is.arr(val);+ const val1 = isRange ? parseFloat(val[0]) : parseFloat(val);+ const val2 = isRange ? parseFloat(val[1]) : 0;+ const unit = getUnit(isRange ? val[1] : val) || 0;+ const start = params.start || 0 + (isRange ? val1 : 0);+ const values = [];+ let maxValue = 0;+ return (el, i, t) => {+ if (fromCenter) fromIndex = (t - 1) / 2;+ if (fromLast) fromIndex = t - 1;+ if (!values.length) {+ for (let index = 0; index < t; index++) {+ if (!grid) {+ values.push(Math.abs(fromIndex - index));+ } else {+ const x = !fromCenter ? fromIndex%grid[0] : (grid[0]-1)/2;+ const y = !fromCenter ? Math.floor(fromIndex/grid[1]) : (grid[1]-1)/2;+ const dx = x - index%grid[0];+ const dy = y - Math.floor(index/grid[1]);+ const currentIndex = Math.sqrt(dx * dx + dy * dy);+ values.push(Math.sqrt(dx * dx + dy * dy));+ }+ maxValue = Math.max(...values);+ }+ }+ let progress = values[i];+ if (easing) progress = easing(progress / maxValue) * maxValue;+ if (direction === 'reverse') progress = Math.abs(maxValue - progress);+ const spacing = isRange ? (val2 - val1) / maxValue : val1;+ return start + (spacing * progress) + unit;+ }+}+// Timelinefunction timeline(params = {}) {@@ -1231,8 +1273,10 @@ anime.setValue = setTargetValue;anime.convertPx = convertPxToUnit;anime.path = getPath;anime.setDashoffset = setDashoffset;+anime.stagger = stagger;anime.timeline = timeline;anime.easing = parseEasings;+anime.penner = penner;anime.random = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;export default anime;\ No newline at end of file