From 0938ad6f40acfb9ffafb059e364a6de467a89be6 Mon Sep 17 00:00:00 2001 From: Tobias K Date: Sat, 19 Jan 2019 21:58:50 +0100 Subject: [PATCH 01/34] fixed value in documentation --- documentation/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/index.html b/documentation/index.html index a7824b73..c2d1e774 100644 --- a/documentation/index.html +++ b/documentation/index.html @@ -2460,7 +2460,7 @@

Time Offsets

.add({ targets: '.offsets-demo .el.triangle', translateX: 250, -}, 0); // absolute offset +}, 400); // absolute offset /*DEMO*/ } From 357678e4b9f542b55614705d0d294fe262cfc238 Mon Sep 17 00:00:00 2001 From: Nick Pannuto Date: Thu, 24 Jan 2019 01:47:58 -0500 Subject: [PATCH 02/34] degres -> degrees Small typo --- documentation/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/index.html b/documentation/index.html index a7824b73..fe3b3702 100644 --- a/documentation/index.html +++ b/documentation/index.html @@ -3215,7 +3215,7 @@

Motion path

'angle' myPath('angle') - Return the current angle value in 'degres' of the SVG path + Return the current angle value in 'degrees' of the SVG path From 52d83ea6499fac19123905cd615b4c101346d61d Mon Sep 17 00:00:00 2001 From: ItsJonQ Date: Sun, 27 Jan 2019 10:10:39 -0500 Subject: [PATCH 03/34] README: Update import/require path in examples This update fixes the import/require paths for the `animejs` module when using it from `node_modules`. Since the paths are defined in `package.json`, node will use `node_modules/animejs/lib` as the root :) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3719dbac..11ac71a8 100644 --- a/README.md +++ b/README.md @@ -37,13 +37,13 @@ or manual [download](https://github.com/juliangarnier/anime/archive/master.zip). #### ES6 modules ```javascript -import anime from 'lib/anime.es.js'; +import anime from 'anime'; ``` #### CommonJS ```javascript -const anime = require('lib/anime.js'); +const anime = require('anime'); ``` #### File include From 8fc492ac7b956e54eee3280d2fa710a126dbaa5b Mon Sep 17 00:00:00 2001 From: Riley Gowan Date: Sun, 27 Jan 2019 10:21:58 -0500 Subject: [PATCH 04/34] Change variable name from seekCild -> seekChild --- lib/anime.es.js | 6 +++--- lib/anime.js | 6 +++--- src/index.js | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/anime.es.js b/lib/anime.es.js index e25346f3..035eed68 100644 --- a/lib/anime.es.js +++ b/lib/anime.es.js @@ -951,15 +951,15 @@ function anime(params) { lastTime = adjustTime(instance.currentTime) * (1 / anime.speed); } - function seekCild(time, child) { + function seekChild(time, child) { if (child) { child.seek(time - child.timelineOffset); } } function syncInstanceChildren(time) { if (!instance.reversePlayback) { - for (var i = 0; i < childrenLength; i++) { seekCild(time, children[i]); } + for (var i = 0; i < childrenLength; i++) { seekChild(time, children[i]); } } else { - for (var i$1 = childrenLength; i$1--;) { seekCild(time, children[i$1]); } + for (var i$1 = childrenLength; i$1--;) { seekChild(time, children[i$1]); } } } diff --git a/lib/anime.js b/lib/anime.js index 7d3d1c1c..b65bee3f 100644 --- a/lib/anime.js +++ b/lib/anime.js @@ -953,15 +953,15 @@ function anime(params) { lastTime = adjustTime(instance.currentTime) * (1 / anime.speed); } - function seekCild(time, child) { + function seekChild(time, child) { if (child) { child.seek(time - child.timelineOffset); } } function syncInstanceChildren(time) { if (!instance.reversePlayback) { - for (var i = 0; i < childrenLength; i++) { seekCild(time, children[i]); } + for (var i = 0; i < childrenLength; i++) { seekChild(time, children[i]); } } else { - for (var i$1 = childrenLength; i$1--;) { seekCild(time, children[i$1]); } + for (var i$1 = childrenLength; i$1--;) { seekChild(time, children[i$1]); } } } diff --git a/src/index.js b/src/index.js index f06be1ea..e053928e 100644 --- a/src/index.js +++ b/src/index.js @@ -931,15 +931,15 @@ function anime(params = {}) { lastTime = adjustTime(instance.currentTime) * (1 / anime.speed); } - function seekCild(time, child) { + function seekChild(time, child) { if (child) child.seek(time - child.timelineOffset); } function syncInstanceChildren(time) { if (!instance.reversePlayback) { - for (let i = 0; i < childrenLength; i++) seekCild(time, children[i]); + for (let i = 0; i < childrenLength; i++) seekChild(time, children[i]); } else { - for (let i = childrenLength; i--;) seekCild(time, children[i]); + for (let i = childrenLength; i--;) seekChild(time, children[i]); } } From ce0fcd404f3618218c994d0ce380478c1dc0ea7a Mon Sep 17 00:00:00 2001 From: whitelight Date: Wed, 30 Jan 2019 17:34:51 -0500 Subject: [PATCH 05/34] Just fixing a little error I noticed ;) --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 7caf091c..df536205 100644 --- a/src/index.js +++ b/src/index.js @@ -1024,7 +1024,7 @@ function anime(params = {}) { const insTime = adjustTime(engineTime); instance.progress = minMax((insTime / insDuration) * 100, 0, 100); instance.reversePlayback = insTime < instance.currentTime; - if (children) { syncInstanceChildren(insTime); }; + if (children) { syncInstanceChildren(insTime); } if (!instance.began && instance.currentTime > 0) { instance.began = true; setCallback('begin'); @@ -1270,4 +1270,4 @@ 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 +export default anime; From b3f851ac53487dd2f1d8ae746f05f5bd4dce804e Mon Sep 17 00:00:00 2001 From: Eric NICOLAS Date: Sat, 2 Feb 2019 22:20:05 +0100 Subject: [PATCH 06/34] Fix a couple of typos Most importantly, `their is` became `there is`. --- documentation/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/index.html b/documentation/index.html index a7824b73..251f11ed 100644 --- a/documentation/index.html +++ b/documentation/index.html @@ -1419,7 +1419,7 @@

Animation keyframes

Animation keyframes are defined using an Array, within the keyframes property.

- If there is no duration specified inside the keyframes, each keyframe duration will be equal to the animation total duration divided by the number of keyframes. + If there is no duration specified inside the keyframes, each keyframe duration will be equal to the animation's total duration divided by the number of keyframes.

@@ -1467,7 +1467,7 @@

Property keyframes

Similar to animation keyframes, property keyframes are defined using an Array of property Object. Property keyframes allow overlapping animations since each property have its own keyframes array.

- If their is no duration specified inside the keyframes, each keyframe duration will be equal to the animation total duration divided by the number of keyframes. + If there is no duration specified inside the keyframes, each keyframe duration will be equal to the animation's total duration divided by the number of keyframes.

From ba35b74830354e3abd3c0fabe3f653586378b3b6 Mon Sep 17 00:00:00 2001 From: Lawrence Gosset Date: Sun, 17 Feb 2019 17:08:19 +0000 Subject: [PATCH 07/34] =?UTF-8?q?Fix=20documentation=20typo=20degres=20?= =?UTF-8?q?=E2=86=92=20degrees?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- documentation/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/index.html b/documentation/index.html index a7824b73..fe3b3702 100644 --- a/documentation/index.html +++ b/documentation/index.html @@ -3215,7 +3215,7 @@

Motion path

- +
'angle' myPath('angle')Return the current angle value in 'degres' of the SVG pathReturn the current angle value in 'degrees' of the SVG path
From 77f129bcd160b190e3250e74d406a9048e27cfef Mon Sep 17 00:00:00 2001 From: YuriFA Date: Tue, 26 Feb 2019 17:33:58 +0300 Subject: [PATCH 08/34] Fix getParentSvgEl with return parent of svg element but not root svg element --- src/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index 7caf091c..d26403f4 100644 --- a/src/index.js +++ b/src/index.js @@ -126,7 +126,7 @@ function elastic(amplitude = 1, period = .5) { const a = minMax(amplitude, 1, 10); const p = minMax(period, .1, 2); return t => { - return (t === 0 || t === 1) ? t : + return (t === 0 || t === 1) ? t : -a * Math.pow(2, 10 * (t - 1)) * Math.sin((((t - 1) - (p / (Math.PI * 2) * Math.asin(1 / a))) * (Math.PI * 2)) / p); } } @@ -262,7 +262,7 @@ const penner = (() => { ] } - let eases = { + let eases = { linear: [0.250, 0.250, 0.750, 0.750] } @@ -523,7 +523,7 @@ function getRectLength(el) { function getLineLength(el) { return getDistance( - {x: getAttribute(el, 'x1'), y: getAttribute(el, 'y1')}, + {x: getAttribute(el, 'x1'), y: getAttribute(el, 'y1')}, {x: getAttribute(el, 'x2'), y: getAttribute(el, 'y2')} ); } @@ -569,8 +569,8 @@ function setDashoffset(el) { function getParentSvgEl(el) { let parentEl = el.parentNode; while (is.svg(parentEl)) { - parentEl = parentEl.parentNode; if (!is.svg(parentEl.parentNode)) break; + parentEl = parentEl.parentNode; } return parentEl; } @@ -858,7 +858,7 @@ let pausedInstances = []; let raf; const engine = (() => { - function play() { + function play() { raf = requestAnimationFrame(step); } function step(t) { From 93cb4b638ba49818f7aec619e49cd217f77f37c0 Mon Sep 17 00:00:00 2001 From: Yuri FA Date: Wed, 27 Feb 2019 10:07:58 +0300 Subject: [PATCH 09/34] Revert removed spaces --- src/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index d26403f4..946d2af6 100644 --- a/src/index.js +++ b/src/index.js @@ -126,7 +126,7 @@ function elastic(amplitude = 1, period = .5) { const a = minMax(amplitude, 1, 10); const p = minMax(period, .1, 2); return t => { - return (t === 0 || t === 1) ? t : + return (t === 0 || t === 1) ? t : -a * Math.pow(2, 10 * (t - 1)) * Math.sin((((t - 1) - (p / (Math.PI * 2) * Math.asin(1 / a))) * (Math.PI * 2)) / p); } } @@ -262,7 +262,7 @@ const penner = (() => { ] } - let eases = { + let eases = { linear: [0.250, 0.250, 0.750, 0.750] } @@ -523,7 +523,7 @@ function getRectLength(el) { function getLineLength(el) { return getDistance( - {x: getAttribute(el, 'x1'), y: getAttribute(el, 'y1')}, + {x: getAttribute(el, 'x1'), y: getAttribute(el, 'y1')}, {x: getAttribute(el, 'x2'), y: getAttribute(el, 'y2')} ); } @@ -858,7 +858,7 @@ let pausedInstances = []; let raf; const engine = (() => { - function play() { + function play() { raf = requestAnimationFrame(step); } function step(t) { @@ -1270,4 +1270,4 @@ 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 +export default anime; From df81656741c26e00c2916156674f9714fa962d87 Mon Sep 17 00:00:00 2001 From: Johan Nordberg Date: Thu, 28 Feb 2019 15:20:31 +0100 Subject: [PATCH 10/34] Set progress to duration instead of 0 when reversed --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 7caf091c..43f42840 100644 --- a/src/index.js +++ b/src/index.js @@ -1093,7 +1093,7 @@ function anime(params = {}) { childrenLength = children.length; for (let i = childrenLength; i--;) instance.children[i].reset(); if (instance.reversed && instance.loop !== true || (direction === 'alternate' && instance.loop === 1)) instance.remaining++; - setAnimationsProgress(0); + setAnimationsProgress(instance.reversed ? instance.duration : 0); } // Set Value helper From 091cb4249b59605c41b06b84678491085c1f26ff Mon Sep 17 00:00:00 2001 From: Ari Lotter Date: Wed, 6 Mar 2019 13:54:46 -0500 Subject: [PATCH 11/34] Allow numeric values with leading '+' and/or with exponent parts. Fixes #551 --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 7caf091c..a661b543 100644 --- a/src/index.js +++ b/src/index.js @@ -625,7 +625,7 @@ function getPathProgress(path, progress) { // Decompose value function decomposeValue(val, unit) { - const rgx = /-?\d*\.?\d+/g; + const rgx = /[-+]?\d*\.?\d+([eE][-+]?\d+)?/g; const value = validateValue((is.pth(val) ? val.totalLength : val), unit) + ''; return { original: value, From d6f3a3c82a5197095c1059f255eb03c1b5a69b3c Mon Sep 17 00:00:00 2001 From: Daniel Ruf Date: Fri, 8 Mar 2019 08:50:11 +0100 Subject: [PATCH 12/34] Remove duplicate CSS properties and rename flex-pack to justify-content --- documentation/assets/css/animejs.css | 1 - documentation/assets/css/documentation.css | 1 - documentation/assets/css/website.css | 1 - documentation/assets/js/website.js | 2 +- 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/documentation/assets/css/animejs.css b/documentation/assets/css/animejs.css index 337af6d9..ef09535c 100644 --- a/documentation/assets/css/animejs.css +++ b/documentation/assets/css/animejs.css @@ -63,7 +63,6 @@ margin: 0; padding: 0; border: 0; - font-size: 100%; font: inherit; vertical-align: baseline; } diff --git a/documentation/assets/css/documentation.css b/documentation/assets/css/documentation.css index e36df003..a0f9f4bb 100644 --- a/documentation/assets/css/documentation.css +++ b/documentation/assets/css/documentation.css @@ -367,7 +367,6 @@ article { z-index: 1; display: flex; align-items: center; - flex-pack: center; justify-content: center; width: 100%; min-height: 200px; diff --git a/documentation/assets/css/website.css b/documentation/assets/css/website.css index 856fb844..be7e3fac 100644 --- a/documentation/assets/css/website.css +++ b/documentation/assets/css/website.css @@ -114,7 +114,6 @@ a:hover .arrow:before, .nav-bar-content { display: flex; flex-shrink: 0; - flex-direction: row; grid-column: 1/13; justify-content: space-between; flex-direction: row; diff --git a/documentation/assets/js/website.js b/documentation/assets/js/website.js index bcd0ad8d..35c28f9c 100644 --- a/documentation/assets/js/website.js +++ b/documentation/assets/js/website.js @@ -235,7 +235,7 @@ var logoAnimation = (function() { targets: '.dot', scale: 1, rotate: '1turn', - scaleY: {value: .5, delay: 0, duration: 150, delay: 230}, + scaleY: {value: .5, duration: 150, delay: 230}, translateX: 430, translateY: [ {value: 244, duration: 100}, From fce16371e3f84d40f40bae0911518af655731931 Mon Sep 17 00:00:00 2001 From: Chris Brown Date: Thu, 28 Mar 2019 16:37:09 +0000 Subject: [PATCH 13/34] Update anime.running reference when clearing array on visibilitychange event --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 7caf091c..5bc3a484 100644 --- a/src/index.js +++ b/src/index.js @@ -890,7 +890,7 @@ function handleVisibilityChange() { if (document.hidden) { activeInstances.forEach(ins => ins.pause()); pausedInstances = activeInstances.slice(0); - activeInstances = []; + anime.running = activeInstances = []; } else { pausedInstances.forEach(ins => ins.play()); } From 75320f30e1878f2a8cd6dae7b96dd0467fc9805f Mon Sep 17 00:00:00 2001 From: Dimitris Raptis Date: Tue, 16 Apr 2019 10:45:39 +0300 Subject: [PATCH 14/34] Fix small typo Change the world "indivudaly" to "individually". --- documentation/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/index.html b/documentation/index.html index a7824b73..cbbb309a 100644 --- a/documentation/index.html +++ b/documentation/index.html @@ -293,7 +293,7 @@

CSS Properties

CSS Transforms

- Animate CSS transforms properties indivudaly. + Animate CSS transforms properties individually.

It's possible to specify different timing for each transforms properties, more details in the specific property parameters section. From 32b4f5acaab145da2e0c6a2884510919eb52beb9 Mon Sep 17 00:00:00 2001 From: Eugene Kopich Date: Thu, 6 Jun 2019 12:00:42 +0300 Subject: [PATCH 15/34] correct sign --- documentation/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/index.html b/documentation/index.html index a7824b73..a7bc5114 100644 --- a/documentation/index.html +++ b/documentation/index.html @@ -1204,7 +1204,7 @@

Relative

easing: 'easeInOutSine' }, rotate: { - value: '+=2turn', // 0 * 2 = '2turn' + value: '+=2turn', // 0 + 2 = '2turn' duration: 1800, easing: 'easeInOutSine' }, From 1556b756986ce4a4cc884032de06c9bb3a31e998 Mon Sep 17 00:00:00 2001 From: Eugene Kopich Date: Thu, 6 Jun 2019 12:13:17 +0300 Subject: [PATCH 16/34] Hexadecimal --- documentation/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/index.html b/documentation/index.html index a7824b73..537dc39d 100644 --- a/documentation/index.html +++ b/documentation/index.html @@ -1220,7 +1220,7 @@

Relative

Colors

- anime.js accepts and converts Haxadecimal, RGB, RGBA, HSL, and HSLA color values. + anime.js accepts and converts Hexadecimal, RGB, RGBA, HSL, and HSLA color values.

CSS color codes ( e.g. : 'red', 'yellow', 'aqua' ) are not supported. @@ -1231,7 +1231,7 @@

Colors

Example - Haxadecimal + Hexadecimal '#FFF' or '#FFFFFF' From 31fae15557e2c345420ce7d4ca0867ef1aa3fbac Mon Sep 17 00:00:00 2001 From: Julian Garnier Date: Tue, 23 Jul 2019 10:32:59 +0200 Subject: [PATCH 17/34] create v3.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 706559ce..a4cd3e40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "animejs", - "version": "3.0.1", + "version": "3.1.0", "homepage": "http://animejs.com", "repository": "juliangarnier/anime", "description": "JavaScript animation engine", From f814d5b5f3ca1f725062d517d7224b8ac4508252 Mon Sep 17 00:00:00 2001 From: Julian Garnier Date: Tue, 23 Jul 2019 10:37:34 +0200 Subject: [PATCH 18/34] Easings refactoring + add Bounce easing --- documentation/index.html | 47 +++++++++++++++--- lib/anime.es.js | 100 +++++++++++++++------------------------ lib/anime.js | 100 +++++++++++++++------------------------ lib/anime.min.js | 4 +- src/index.js | 92 +++++++++++++---------------------- 5 files changed, 150 insertions(+), 193 deletions(-) diff --git a/documentation/index.html b/documentation/index.html index a7824b73..bb9a74e8 100644 --- a/documentation/index.html +++ b/documentation/index.html @@ -3436,6 +3436,11 @@

Penner's functions

'easeOutBack' 'easeInOutBack' + + 'easeInBounce' + 'easeOutBounce' + 'easeInOutBounce' +
@@ -3445,10 +3450,39 @@

Penner's functions

/*DEMO*/ var demoContentEl = document.querySelector('.penner-equations-demo'); var fragment = document.createDocumentFragment(); +var easingNames = [ + 'easeInQuad', + 'easeInCubic', + 'easeInQuart', + 'easeInQuint', + 'easeInSine', + 'easeInExpo', + 'easeInCirc', + 'easeInBack', + 'easeInBounce', + 'easeInOutQuad', + 'easeInOutCubic', + 'easeInOutQuart', + 'easeInOutQuint', + 'easeInOutSine', + 'easeInOutExpo', + 'easeInOutCirc', + 'easeInOutBack', + 'easeInOutBounce', + 'easeOutQuad', + 'easeOutCubic', + 'easeOutQuart', + 'easeOutQuint', + 'easeOutSine', + 'easeOutExpo', + 'easeOutCirc', + 'easeOutBack', + 'easeOutBounce' +] function createEasingDemo(easing) { var demoEl = document.createElement('div'); - demoEl.classList.add('stretched','square','el'); + demoEl.classList.add('stretched','square','el', 'easing-'+easing); anime({ targets: demoEl, translateX: 250, @@ -3456,16 +3490,15 @@

Penner's functions

loop: true, delay: 200, endDelay: 200, - easing: easing, + duration: 2000, + easing: easing }); fragment.appendChild(demoEl); } -for (var easeName in anime.penner) { - if (Array.isArray(anime.penner[easeName])) { - createEasingDemo(easeName); - } -} +easingNames.forEach(function(easeName) { + createEasingDemo(easeName); +}); demoContentEl.innerHTML = ''; demoContentEl.appendChild(fragment); diff --git a/lib/anime.es.js b/lib/anime.es.js index 2a26911b..9c52d3b1 100644 --- a/lib/anime.es.js +++ b/lib/anime.es.js @@ -1,5 +1,5 @@ /* - * anime.js v3.0.1 + * anime.js v3.1.0 * (c) 2019 Julian Garnier * Released under the MIT license * animejs.com @@ -127,20 +127,6 @@ function spring(string, duration) { } -// Elastic easing adapted from jQueryUI http://api.jqueryui.com/easings/ - -function elastic(amplitude, period) { - if ( amplitude === void 0 ) amplitude = 1; - if ( period === void 0 ) period = .5; - - var a = minMax(amplitude, 1, 10); - var p = minMax(period, .1, 2); - return function (t) { - return (t === 0 || t === 1) ? t : - -a * Math.pow(2, 10 * (t - 1)) * Math.sin((((t - 1) - (p / (Math.PI * 2) * Math.asin(1 / a))) * (Math.PI * 2)) / p); - } -} - // Basic steps easing implementation https://developer.mozilla.org/fr/docs/Web/CSS/transition-timing-function function steps(steps) { @@ -234,57 +220,45 @@ var bezier = (function () { var penner = (function () { - var names = ['Quad', 'Cubic', 'Quart', 'Quint', 'Sine', 'Expo', 'Circ', 'Back', 'Elastic']; - - // Approximated Penner equations http://matthewlein.com/ceaser/ - - var curves = { - In: [ - [0.550, 0.085, 0.680, 0.530], /* inQuad */ - [0.550, 0.055, 0.675, 0.190], /* inCubic */ - [0.895, 0.030, 0.685, 0.220], /* inQuart */ - [0.755, 0.050, 0.855, 0.060], /* inQuint */ - [0.470, 0.000, 0.745, 0.715], /* inSine */ - [0.950, 0.050, 0.795, 0.035], /* inExpo */ - [0.600, 0.040, 0.980, 0.335], /* inCirc */ - [0.600,-0.280, 0.735, 0.045], /* inBack */ - elastic /* inElastic */ - ], - Out: [ - [0.250, 0.460, 0.450, 0.940], /* outQuad */ - [0.215, 0.610, 0.355, 1.000], /* outCubic */ - [0.165, 0.840, 0.440, 1.000], /* outQuart */ - [0.230, 1.000, 0.320, 1.000], /* outQuint */ - [0.390, 0.575, 0.565, 1.000], /* outSine */ - [0.190, 1.000, 0.220, 1.000], /* outExpo */ - [0.075, 0.820, 0.165, 1.000], /* outCirc */ - [0.175, 0.885, 0.320, 1.275], /* outBack */ - function (a, p) { return function (t) { return 1 - elastic(a, p)(1 - t); }; } /* outElastic */ - ], - InOut: [ - [0.455, 0.030, 0.515, 0.955], /* inOutQuad */ - [0.645, 0.045, 0.355, 1.000], /* inOutCubic */ - [0.770, 0.000, 0.175, 1.000], /* inOutQuart */ - [0.860, 0.000, 0.070, 1.000], /* inOutQuint */ - [0.445, 0.050, 0.550, 0.950], /* inOutSine */ - [1.000, 0.000, 0.000, 1.000], /* inOutExpo */ - [0.785, 0.135, 0.150, 0.860], /* inOutCirc */ - [0.680,-0.550, 0.265, 1.550], /* inOutBack */ - function (a, p) { return function (t) { return t < .5 ? elastic(a, p)(t * 2) / 2 : 1 - elastic(a, p)(t * -2 + 2) / 2; }; } /* inOutElastic */ - ] + // Based on jQuery UI's implemenation of easing equations from Robert Penner (http://www.robertpenner.com/easing) + + var eases = { linear: function () { return function (t) { return t; }; } }; + + var functionEasings = { + Sine: function () { return function (t) { return 1 - Math.cos(t * Math.PI / 2); }; }, + Circ: function () { return function (t) { return 1 - Math.sqrt(1 - t * t); }; }, + Back: function () { return function (t) { return t * t * (3 * t - 2); }; }, + Bounce: function () { return function (t) { + var pow2, b = 4; + while (t < (( pow2 = Math.pow(2, --b)) - 1) / 11) {} + return 1 / Math.pow(4, 3 - b) - 7.5625 * Math.pow(( pow2 * 3 - 2 ) / 22 - t, 2) + }; }, + Elastic: function (amplitude, period) { + if ( amplitude === void 0 ) amplitude = 1; + if ( period === void 0 ) period = .5; + + var a = minMax(amplitude, 1, 10); + var p = minMax(period, .1, 2); + return function (t) { + return (t === 0 || t === 1) ? t : + -a * Math.pow(2, 10 * (t - 1)) * Math.sin((((t - 1) - (p / (Math.PI * 2) * Math.asin(1 / a))) * (Math.PI * 2)) / p); + } + } }; - var eases = { - linear: [0.250, 0.250, 0.750, 0.750] - }; + var baseEasings = ['Quad', 'Cubic', 'Quart', 'Quint', 'Expo']; - var loop = function ( coords ) { - curves[coords].forEach(function (ease, i) { - eases['ease'+coords+names[i]] = ease; - }); - }; + baseEasings.forEach(function (name, i) { + functionEasings[name] = function () { return function (t) { return Math.pow(t, i + 2); }; }; + }); - for (var coords in curves) loop( coords ); + Object.keys(functionEasings).forEach(function (name) { + var easeIn = functionEasings[name]; + eases['easeIn' + name] = easeIn; + eases['easeOut' + name] = function (a, b) { return function (t) { return 1 - easeIn(a, b)(1 - t); }; }; + eases['easeInOut' + name] = function (a, b) { return function (t) { return t < 0.5 ? easeIn(a, b)(t * 2) / 2 : + 1 - easeIn(a, b)(t * -2 + 2) / 2; }; }; + }); return eases; @@ -299,7 +273,7 @@ function parseEasings(easing, duration) { case 'spring' : return spring(easing, duration); case 'cubicBezier' : return applyArguments(bezier, args); case 'steps' : return applyArguments(steps, args); - default : return is.fnc(ease) ? applyArguments(ease, args) : applyArguments(bezier, ease); + default : return applyArguments(ease, args); } } diff --git a/lib/anime.js b/lib/anime.js index 7bde123d..f48317e5 100644 --- a/lib/anime.js +++ b/lib/anime.js @@ -1,5 +1,5 @@ /* - * anime.js v3.0.1 + * anime.js v3.1.0 * (c) 2019 Julian Garnier * Released under the MIT license * animejs.com @@ -129,20 +129,6 @@ function spring(string, duration) { } -// Elastic easing adapted from jQueryUI http://api.jqueryui.com/easings/ - -function elastic(amplitude, period) { - if ( amplitude === void 0 ) amplitude = 1; - if ( period === void 0 ) period = .5; - - var a = minMax(amplitude, 1, 10); - var p = minMax(period, .1, 2); - return function (t) { - return (t === 0 || t === 1) ? t : - -a * Math.pow(2, 10 * (t - 1)) * Math.sin((((t - 1) - (p / (Math.PI * 2) * Math.asin(1 / a))) * (Math.PI * 2)) / p); - } -} - // Basic steps easing implementation https://developer.mozilla.org/fr/docs/Web/CSS/transition-timing-function function steps(steps) { @@ -236,57 +222,45 @@ var bezier = (function () { var penner = (function () { - var names = ['Quad', 'Cubic', 'Quart', 'Quint', 'Sine', 'Expo', 'Circ', 'Back', 'Elastic']; - - // Approximated Penner equations http://matthewlein.com/ceaser/ - - var curves = { - In: [ - [0.550, 0.085, 0.680, 0.530], /* inQuad */ - [0.550, 0.055, 0.675, 0.190], /* inCubic */ - [0.895, 0.030, 0.685, 0.220], /* inQuart */ - [0.755, 0.050, 0.855, 0.060], /* inQuint */ - [0.470, 0.000, 0.745, 0.715], /* inSine */ - [0.950, 0.050, 0.795, 0.035], /* inExpo */ - [0.600, 0.040, 0.980, 0.335], /* inCirc */ - [0.600,-0.280, 0.735, 0.045], /* inBack */ - elastic /* inElastic */ - ], - Out: [ - [0.250, 0.460, 0.450, 0.940], /* outQuad */ - [0.215, 0.610, 0.355, 1.000], /* outCubic */ - [0.165, 0.840, 0.440, 1.000], /* outQuart */ - [0.230, 1.000, 0.320, 1.000], /* outQuint */ - [0.390, 0.575, 0.565, 1.000], /* outSine */ - [0.190, 1.000, 0.220, 1.000], /* outExpo */ - [0.075, 0.820, 0.165, 1.000], /* outCirc */ - [0.175, 0.885, 0.320, 1.275], /* outBack */ - function (a, p) { return function (t) { return 1 - elastic(a, p)(1 - t); }; } /* outElastic */ - ], - InOut: [ - [0.455, 0.030, 0.515, 0.955], /* inOutQuad */ - [0.645, 0.045, 0.355, 1.000], /* inOutCubic */ - [0.770, 0.000, 0.175, 1.000], /* inOutQuart */ - [0.860, 0.000, 0.070, 1.000], /* inOutQuint */ - [0.445, 0.050, 0.550, 0.950], /* inOutSine */ - [1.000, 0.000, 0.000, 1.000], /* inOutExpo */ - [0.785, 0.135, 0.150, 0.860], /* inOutCirc */ - [0.680,-0.550, 0.265, 1.550], /* inOutBack */ - function (a, p) { return function (t) { return t < .5 ? elastic(a, p)(t * 2) / 2 : 1 - elastic(a, p)(t * -2 + 2) / 2; }; } /* inOutElastic */ - ] + // Based on jQuery UI's implemenation of easing equations from Robert Penner (http://www.robertpenner.com/easing) + + var eases = { linear: function () { return function (t) { return t; }; } }; + + var functionEasings = { + Sine: function () { return function (t) { return 1 - Math.cos(t * Math.PI / 2); }; }, + Circ: function () { return function (t) { return 1 - Math.sqrt(1 - t * t); }; }, + Back: function () { return function (t) { return t * t * (3 * t - 2); }; }, + Bounce: function () { return function (t) { + var pow2, b = 4; + while (t < (( pow2 = Math.pow(2, --b)) - 1) / 11) {} + return 1 / Math.pow(4, 3 - b) - 7.5625 * Math.pow(( pow2 * 3 - 2 ) / 22 - t, 2) + }; }, + Elastic: function (amplitude, period) { + if ( amplitude === void 0 ) amplitude = 1; + if ( period === void 0 ) period = .5; + + var a = minMax(amplitude, 1, 10); + var p = minMax(period, .1, 2); + return function (t) { + return (t === 0 || t === 1) ? t : + -a * Math.pow(2, 10 * (t - 1)) * Math.sin((((t - 1) - (p / (Math.PI * 2) * Math.asin(1 / a))) * (Math.PI * 2)) / p); + } + } }; - var eases = { - linear: [0.250, 0.250, 0.750, 0.750] - }; + var baseEasings = ['Quad', 'Cubic', 'Quart', 'Quint', 'Expo']; - var loop = function ( coords ) { - curves[coords].forEach(function (ease, i) { - eases['ease'+coords+names[i]] = ease; - }); - }; + baseEasings.forEach(function (name, i) { + functionEasings[name] = function () { return function (t) { return Math.pow(t, i + 2); }; }; + }); - for (var coords in curves) loop( coords ); + Object.keys(functionEasings).forEach(function (name) { + var easeIn = functionEasings[name]; + eases['easeIn' + name] = easeIn; + eases['easeOut' + name] = function (a, b) { return function (t) { return 1 - easeIn(a, b)(1 - t); }; }; + eases['easeInOut' + name] = function (a, b) { return function (t) { return t < 0.5 ? easeIn(a, b)(t * 2) / 2 : + 1 - easeIn(a, b)(t * -2 + 2) / 2; }; }; + }); return eases; @@ -301,7 +275,7 @@ function parseEasings(easing, duration) { case 'spring' : return spring(easing, duration); case 'cubicBezier' : return applyArguments(bezier, args); case 'steps' : return applyArguments(steps, args); - default : return is.fnc(ease) ? applyArguments(ease, args) : applyArguments(bezier, ease); + default : return applyArguments(ease, args); } } diff --git a/lib/anime.min.js b/lib/anime.min.js index 3f0baf1c..0f84643a 100644 --- a/lib/anime.min.js +++ b/lib/anime.min.js @@ -1,8 +1,8 @@ /* - * anime.js v3.0.1 + * anime.js v3.1.0 * (c) 2019 Julian Garnier * Released under the MIT license * animejs.com */ -!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):n.anime=e()}(this,function(){"use strict";var n={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0},e={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},r=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective"],t={CSS:{},springs:{}};function a(n,e,r){return Math.min(Math.max(n,e),r)}function o(n,e){return n.indexOf(e)>-1}function i(n,e){return n.apply(null,e)}var u={arr:function(n){return Array.isArray(n)},obj:function(n){return o(Object.prototype.toString.call(n),"Object")},pth:function(n){return u.obj(n)&&n.hasOwnProperty("totalLength")},svg:function(n){return n instanceof SVGElement},inp:function(n){return n instanceof HTMLInputElement},dom:function(n){return n.nodeType||u.svg(n)},str:function(n){return"string"==typeof n},fnc:function(n){return"function"==typeof n},und:function(n){return void 0===n},hex:function(n){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(n)},rgb:function(n){return/^rgb/.test(n)},hsl:function(n){return/^hsl/.test(n)},col:function(n){return u.hex(n)||u.rgb(n)||u.hsl(n)},key:function(r){return!n.hasOwnProperty(r)&&!e.hasOwnProperty(r)&&"targets"!==r&&"keyframes"!==r}};function s(n){var e=/\(([^)]+)\)/.exec(n);return e?e[1].split(",").map(function(n){return parseFloat(n)}):[]}function c(n,e){var r=s(n),o=a(u.und(r[0])?1:r[0],.1,100),i=a(u.und(r[1])?100:r[1],.1,100),c=a(u.und(r[2])?10:r[2],.1,100),f=a(u.und(r[3])?0:r[3],.1,100),l=Math.sqrt(i/o),d=c/(2*Math.sqrt(i*o)),p=d<1?l*Math.sqrt(1-d*d):0,v=1,h=d<1?(d*l-f)/p:-f+l;function g(n){var r=e?e*n/1e3:n;return r=d<1?Math.exp(-r*d*l)*(v*Math.cos(p*r)+h*Math.sin(p*r)):(v+h*r)*Math.exp(-r*l),0===n||1===n?n:1-r}return e?g:function(){var e=t.springs[n];if(e)return e;for(var r=0,a=0;;)if(1===g(r+=1/6)){if(++a>=16)break}else a=0;var o=r*(1/6)*1e3;return t.springs[n]=o,o}}function f(n,e){void 0===n&&(n=1),void 0===e&&(e=.5);var r=a(n,1,10),t=a(e,.1,2);return function(n){return 0===n||1===n?n:-r*Math.pow(2,10*(n-1))*Math.sin((n-1-t/(2*Math.PI)*Math.asin(1/r))*(2*Math.PI)/t)}}function l(n){return void 0===n&&(n=10),function(e){return Math.round(e*n)*(1/n)}}var d=function(){var n=11,e=1/(n-1);function r(n,e){return 1-3*e+3*n}function t(n,e){return 3*e-6*n}function a(n){return 3*n}function o(n,e,o){return((r(e,o)*n+t(e,o))*n+a(e))*n}function i(n,e,o){return 3*r(e,o)*n*n+2*t(e,o)*n+a(e)}return function(r,t,a,u){if(0<=r&&r<=1&&0<=a&&a<=1){var s=new Float32Array(n);if(r!==t||a!==u)for(var c=0;c=.001?function(n,e,r,t){for(var a=0;a<4;++a){var u=i(e,r,t);if(0===u)return e;e-=(o(e,r,t)-n)/u}return e}(t,l,r,a):0===d?l:function(n,e,r,t,a){for(var i,u,s=0;(i=o(u=e+(r-e)/2,t,a)-n)>0?r=u:e=u,Math.abs(i)>1e-7&&++s<10;);return u}(t,u,u+e,r,a)}}}(),p=function(){var n=["Quad","Cubic","Quart","Quint","Sine","Expo","Circ","Back","Elastic"],e={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(n,e){return function(r){return 1-f(n,e)(1-r)}}],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(n,e){return function(r){return r<.5?f(n,e)(2*r)/2:1-f(n,e)(-2*r+2)/2}}]},r={linear:[.25,.25,.75,.75]},t=function(t){e[t].forEach(function(e,a){r["ease"+t+n[a]]=e})};for(var a in e)t(a);return r}();function v(n,e){if(u.fnc(n))return n;var r=n.split("(")[0],t=p[r],a=s(n);switch(r){case"spring":return c(n,e);case"cubicBezier":return i(d,a);case"steps":return i(l,a);default:return u.fnc(t)?i(t,a):i(d,t)}}function h(n){try{return document.querySelectorAll(n)}catch(n){return}}function g(n,e){for(var r=n.length,t=arguments.length>=2?arguments[1]:void 0,a=[],o=0;o1&&(r-=1),r<1/6?n+6*(e-n)*r:r<.5?e:r<2/3?n+(e-n)*(2/3-r)*6:n}if(0==i)e=r=t=u;else{var f=u<.5?u*(1+i):u+i-u*i,l=2*u-f;e=c(l,f,o+1/3),r=c(l,f,o),t=c(l,f,o-1/3)}return"rgba("+255*e+","+255*r+","+255*t+","+s+")"}(n):void 0;var e,r,t,a}function C(n){var e=/([\+\-]?[0-9#\.]+)(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(n);if(e)return e[2]}function O(n,e){return u.fnc(n)?n(e.target,e.id,e.total):n}function P(n,e){return n.getAttribute(e)}function I(n,e,r){if(b([r,"deg","rad","turn"],C(e)))return e;var a=t.CSS[e+r];if(!u.und(a))return a;var o=document.createElement(n.tagName),i=n.parentNode&&n.parentNode!==document?n.parentNode:document.body;i.appendChild(o),o.style.position="absolute",o.style.width=100+r;var s=100/o.offsetWidth;i.removeChild(o);var c=s*parseFloat(e);return t.CSS[e+r]=c,c}function B(n,e,r){if(e in n.style){var t=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),a=n.style[e]||getComputedStyle(n).getPropertyValue(t)||"0";return r?I(n,a,r):a}}function D(n,e){return u.dom(n)&&!u.inp(n)&&(P(n,e)||u.svg(n)&&n[e])?"attribute":u.dom(n)&&b(r,e)?"transform":u.dom(n)&&"transform"!==e&&B(n,e)?"css":null!=n[e]?"object":void 0}function T(n){if(u.dom(n)){for(var e,r=n.style.transform||"",t=/(\w+)\(([^)]*)\)/g,a=new Map;e=t.exec(r);)a.set(e[1],e[2]);return a}}function F(n,e,r,t){var a,i=o(e,"scale")?1:0+(o(a=e,"translate")||"perspective"===a?"px":o(a,"rotate")||o(a,"skew")?"deg":void 0),u=T(n).get(e)||i;return r&&(r.transforms.list.set(e,u),r.transforms.last=e),t?I(n,u,t):u}function N(n,e,r,t){switch(D(n,e)){case"transform":return F(n,e,t,r);case"css":return B(n,e,r);case"attribute":return P(n,e);default:return n[e]||0}}function A(n,e){var r=/^(\*=|\+=|-=)/.exec(n);if(!r)return n;var t=C(n)||0,a=parseFloat(e),o=parseFloat(n.replace(r[0],""));switch(r[0][0]){case"+":return a+o+t;case"-":return a-o+t;case"*":return a*o+t}}function E(n,e){if(u.col(n))return k(n);var r=C(n),t=r?n.substr(0,n.length-r.length):n;return e&&!/\s/g.test(n)?t+e:t}function L(n,e){return Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2))}function S(n){for(var e,r=n.points,t=0,a=0;a0&&(t+=L(e,o)),e=o}return t}function j(n){if(n.getTotalLength)return n.getTotalLength();switch(n.tagName.toLowerCase()){case"circle":return o=n,2*Math.PI*P(o,"r");case"rect":return 2*P(a=n,"width")+2*P(a,"height");case"line":return L({x:P(t=n,"x1"),y:P(t,"y1")},{x:P(t,"x2"),y:P(t,"y2")});case"polyline":return S(n);case"polygon":return r=(e=n).points,S(e)+L(r.getItem(r.numberOfItems-1),r.getItem(0))}var e,r,t,a,o}function q(n,e){var r=e||{},t=r.el||function(n){for(var e=n.parentNode;u.svg(e)&&(e=e.parentNode,u.svg(e.parentNode)););return e}(n),a=t.getBoundingClientRect(),o=P(t,"viewBox"),i=a.width,s=a.height,c=r.viewBox||(o?o.split(" "):[0,0,i,s]);return{el:t,viewBox:c,x:c[0]/1,y:c[1]/1,w:i/c[2],h:s/c[3]}}function $(n,e){function r(r){void 0===r&&(r=0);var t=e+r>=1?e+r:0;return n.el.getPointAtLength(t)}var t=q(n.el,n.svg),a=r(),o=r(-1),i=r(1);switch(n.property){case"x":return(a.x-t.x)*t.w;case"y":return(a.y-t.y)*t.h;case"angle":return 180*Math.atan2(i.y-o.y,i.x-o.x)/Math.PI}}function X(n,e){var r=/-?\d*\.?\d+/g,t=E(u.pth(n)?n.totalLength:n,e)+"";return{original:t,numbers:t.match(r)?t.match(r).map(Number):[0],strings:u.str(n)||e?t.split(r):[]}}function Y(n){return g(n?m(u.arr(n)?n.map(y):y(n)):[],function(n,e,r){return r.indexOf(n)===e})}function Z(n){var e=Y(n);return e.map(function(n,r){return{target:n,id:r,total:e.length,transforms:{list:T(n)}}})}function Q(n,e){var r=x(e);if(/^spring/.test(r.easing)&&(r.duration=c(r.easing)),u.arr(n)){var t=n.length;2===t&&!u.obj(n[0])?n={value:n}:u.fnc(e.duration)||(r.duration=e.duration/t)}var a=u.arr(n)?n:[n];return a.map(function(n,r){var t=u.obj(n)&&!u.pth(n)?n:{value:n};return u.und(t.delay)&&(t.delay=r?0:e.delay),u.und(t.endDelay)&&(t.endDelay=r===a.length-1?e.endDelay:0),t}).map(function(n){return w(n,r)})}function V(n,e){var r=[],t=e.keyframes;for(var a in t&&(e=w(function(n){for(var e=g(m(n.map(function(n){return Object.keys(n)})),function(n){return u.key(n)}).reduce(function(n,e){return n.indexOf(e)<0&&n.push(e),n},[]),r={},t=function(t){var a=e[t];r[a]=n.map(function(n){var e={};for(var r in n)u.key(r)?r==a&&(e.value=n[r]):e[r]=n[r];return e})},a=0;a-1&&(U.splice(o,1),r=U.length)}else a.tick(e);t++}n()}else K=cancelAnimationFrame(K)}return n}();function en(r){void 0===r&&(r={});var t,o=0,i=0,u=0,s=0,c=null;function f(n){var e=window.Promise&&new Promise(function(n){return c=n});return n.finished=e,e}var l,d,p,v,h,m,y,b,x=(d=M(n,l=r),p=M(e,l),v=V(p,l),h=Z(l.targets),m=R(h,v),y=W(m,p),b=J,J++,w(d,{id:b,children:[],animatables:h,animations:m,duration:y.duration,delay:y.delay,endDelay:y.endDelay}));f(x);function k(){var n=x.direction;"alternate"!==n&&(x.direction="normal"!==n?"normal":"reverse"),x.reversed=!x.reversed,t.forEach(function(n){return n.reversed=x.reversed})}function C(n){return x.reversed?x.duration-n:n}function O(){o=0,i=C(x.currentTime)*(1/en.speed)}function P(n,e){e&&e.seek(n-e.timelineOffset)}function I(n){for(var e=0,r=x.animations,t=r.length;e2||(b=Math.round(b*p)/p)),v.push(b)}var k=d.length;if(k){m=d[0];for(var C=0;C0&&(x.began=!0,B("begin"),B("loopBegin")),d<=r&&0!==x.currentTime&&I(0),(d>=l&&x.currentTime!==e||!e)&&I(e),d>r&&d=e&&(i=0,x.remaining&&!0!==x.remaining&&x.remaining--,x.remaining?(o=u,B("loopComplete"),B("loopBegin"),"alternate"===x.direction&&k()):(x.paused=!0,x.completed||(x.completed=!0,B("loopComplete"),B("complete"),!x.passThrough&&"Promise"in window&&(c(),f(x)))))}return x.reset=function(){var n=x.direction;x.passThrough=!1,x.currentTime=0,x.progress=0,x.paused=!0,x.began=!1,x.changeBegan=!1,x.completed=!1,x.changeCompleted=!1,x.reversePlayback=!1,x.reversed="reverse"===n,x.remaining=x.loop,t=x.children;for(var e=s=t.length;e--;)x.children[e].reset();(x.reversed&&!0!==x.loop||"alternate"===n&&1===x.loop)&&x.remaining++,I(0)},x.set=function(n,e){return G(n,e),x},x.tick=function(n){u=n,o||(o=u),D((u+(i-o))*en.speed)},x.seek=function(n){D(C(n))},x.pause=function(){x.paused=!0,O()},x.play=function(){x.paused&&(x.completed&&x.reset(),x.paused=!1,U.push(x),O(),K||nn())},x.reverse=function(){k(),O()},x.restart=function(){x.reset(),x.play()},x.reset(),x.autoplay&&x.play(),x}function rn(n,e){for(var r=e.length;r--;)b(n,e[r].animatable.target)&&e.splice(r,1)}return"undefined"!=typeof document&&document.addEventListener("visibilitychange",function(){document.hidden?(U.forEach(function(n){return n.pause()}),_=U.slice(0),U=[]):_.forEach(function(n){return n.play()})}),en.version="3.0.1",en.speed=1,en.running=U,en.remove=function(n){for(var e=Y(n),r=U.length;r--;){var t=U[r],a=t.animations,o=t.children;rn(e,a);for(var i=o.length;i--;){var u=o[i],s=u.animations;rn(e,s),s.length||u.children.length||o.splice(i,1)}a.length||o.length||t.pause()}},en.get=N,en.set=G,en.convertPx=I,en.path=function(n,e){var r=u.str(n)?h(n)[0]:n,t=e||100;return function(n){return{property:n,el:r,svg:q(r),totalLength:j(r)*(t/100)}}},en.setDashoffset=function(n){var e=j(n);return n.setAttribute("stroke-dasharray",e),e},en.stagger=function(n,e){void 0===e&&(e={});var r=e.direction||"normal",t=e.easing?v(e.easing):null,a=e.grid,o=e.axis,i=e.from||0,s="first"===i,c="center"===i,f="last"===i,l=u.arr(n),d=l?parseFloat(n[0]):parseFloat(n),p=l?parseFloat(n[1]):0,h=C(l?n[1]:n)||0,g=e.start||0+(l?d:0),m=[],y=0;return function(n,e,u){if(s&&(i=0),c&&(i=(u-1)/2),f&&(i=u-1),!m.length){for(var v=0;v-1&&U.splice(o,1);for(var c=0;c-1}function u(n,e){return n.apply(null,e)}var i={arr:function(n){return Array.isArray(n)},obj:function(n){return o(Object.prototype.toString.call(n),"Object")},pth:function(n){return i.obj(n)&&n.hasOwnProperty("totalLength")},svg:function(n){return n instanceof SVGElement},inp:function(n){return n instanceof HTMLInputElement},dom:function(n){return n.nodeType||i.svg(n)},str:function(n){return"string"==typeof n},fnc:function(n){return"function"==typeof n},und:function(n){return void 0===n},hex:function(n){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(n)},rgb:function(n){return/^rgb/.test(n)},hsl:function(n){return/^hsl/.test(n)},col:function(n){return i.hex(n)||i.rgb(n)||i.hsl(n)},key:function(t){return!n.hasOwnProperty(t)&&!e.hasOwnProperty(t)&&"targets"!==t&&"keyframes"!==t}};function c(n){var e=/\(([^)]+)\)/.exec(n);return e?e[1].split(",").map(function(n){return parseFloat(n)}):[]}function s(n,e){var t=c(n),o=a(i.und(t[0])?1:t[0],.1,100),u=a(i.und(t[1])?100:t[1],.1,100),s=a(i.und(t[2])?10:t[2],.1,100),f=a(i.und(t[3])?0:t[3],.1,100),l=Math.sqrt(u/o),d=s/(2*Math.sqrt(u*o)),p=d<1?l*Math.sqrt(1-d*d):0,h=1,v=d<1?(d*l-f)/p:-f+l;function g(n){var t=e?e*n/1e3:n;return t=d<1?Math.exp(-t*d*l)*(h*Math.cos(p*t)+v*Math.sin(p*t)):(h+v*t)*Math.exp(-t*l),0===n||1===n?n:1-t}return e?g:function(){var e=r.springs[n];if(e)return e;for(var t=0,a=0;;)if(1===g(t+=1/6)){if(++a>=16)break}else a=0;var o=t*(1/6)*1e3;return r.springs[n]=o,o}}function f(n){return void 0===n&&(n=10),function(e){return Math.round(e*n)*(1/n)}}var l,d,p=function(){var n=11,e=1/(n-1);function t(n,e){return 1-3*e+3*n}function r(n,e){return 3*e-6*n}function a(n){return 3*n}function o(n,e,o){return((t(e,o)*n+r(e,o))*n+a(e))*n}function u(n,e,o){return 3*t(e,o)*n*n+2*r(e,o)*n+a(e)}return function(t,r,a,i){if(0<=t&&t<=1&&0<=a&&a<=1){var c=new Float32Array(n);if(t!==r||a!==i)for(var s=0;s=.001?function(n,e,t,r){for(var a=0;a<4;++a){var i=u(e,t,r);if(0===i)return e;e-=(o(e,t,r)-n)/i}return e}(r,l,t,a):0===d?l:function(n,e,t,r,a){for(var u,i,c=0;(u=o(i=e+(t-e)/2,r,a)-n)>0?t=i:e=i,Math.abs(u)>1e-7&&++c<10;);return i}(r,i,i+e,t,a)}}}(),h=(l={linear:function(){return function(n){return n}}},d={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var e,t=4;n<((e=Math.pow(2,--t))-1)/11;);return 1/Math.pow(4,3-t)-7.5625*Math.pow((3*e-2)/22-n,2)}},Elastic:function(n,e){void 0===n&&(n=1),void 0===e&&(e=.5);var t=a(n,1,10),r=a(e,.1,2);return function(n){return 0===n||1===n?n:-t*Math.pow(2,10*(n-1))*Math.sin((n-1-r/(2*Math.PI)*Math.asin(1/t))*(2*Math.PI)/r)}}},["Quad","Cubic","Quart","Quint","Expo"].forEach(function(n,e){d[n]=function(){return function(n){return Math.pow(n,e+2)}}}),Object.keys(d).forEach(function(n){var e=d[n];l["easeIn"+n]=e,l["easeOut"+n]=function(n,t){return function(r){return 1-e(n,t)(1-r)}},l["easeInOut"+n]=function(n,t){return function(r){return r<.5?e(n,t)(2*r)/2:1-e(n,t)(-2*r+2)/2}}}),l);function v(n,e){if(i.fnc(n))return n;var t=n.split("(")[0],r=h[t],a=c(n);switch(t){case"spring":return s(n,e);case"cubicBezier":return u(p,a);case"steps":return u(f,a);default:return u(r,a)}}function g(n){try{return document.querySelectorAll(n)}catch(n){return}}function m(n,e){for(var t=n.length,r=arguments.length>=2?arguments[1]:void 0,a=[],o=0;o1&&(t-=1),t<1/6?n+6*(e-n)*t:t<.5?e:t<2/3?n+(e-n)*(2/3-t)*6:n}if(0==u)e=t=r=i;else{var f=i<.5?i*(1+u):i+u-i*u,l=2*i-f;e=s(l,f,o+1/3),t=s(l,f,o),r=s(l,f,o-1/3)}return"rgba("+255*e+","+255*t+","+255*r+","+c+")"}(n):void 0;var e,t,r,a}function C(n){var e=/([\+\-]?[0-9#\.]+)(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(n);if(e)return e[2]}function P(n,e){return i.fnc(n)?n(e.target,e.id,e.total):n}function I(n,e){return n.getAttribute(e)}function B(n,e,t){if(M([t,"deg","rad","turn"],C(e)))return e;var a=r.CSS[e+t];if(!i.und(a))return a;var o=document.createElement(n.tagName),u=n.parentNode&&n.parentNode!==document?n.parentNode:document.body;u.appendChild(o),o.style.position="absolute",o.style.width=100+t;var c=100/o.offsetWidth;u.removeChild(o);var s=c*parseFloat(e);return r.CSS[e+t]=s,s}function D(n,e,t){if(e in n.style){var r=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),a=n.style[e]||getComputedStyle(n).getPropertyValue(r)||"0";return t?B(n,a,t):a}}function T(n,e){return i.dom(n)&&!i.inp(n)&&(I(n,e)||i.svg(n)&&n[e])?"attribute":i.dom(n)&&M(t,e)?"transform":i.dom(n)&&"transform"!==e&&D(n,e)?"css":null!=n[e]?"object":void 0}function E(n){if(i.dom(n)){for(var e,t=n.style.transform||"",r=/(\w+)\(([^)]*)\)/g,a=new Map;e=r.exec(t);)a.set(e[1],e[2]);return a}}function F(n,e,t,r){var a,u=o(e,"scale")?1:0+(o(a=e,"translate")||"perspective"===a?"px":o(a,"rotate")||o(a,"skew")?"deg":void 0),i=E(n).get(e)||u;return t&&(t.transforms.list.set(e,i),t.transforms.last=e),r?B(n,i,r):i}function N(n,e,t,r){switch(T(n,e)){case"transform":return F(n,e,r,t);case"css":return D(n,e,t);case"attribute":return I(n,e);default:return n[e]||0}}function A(n,e){var t=/^(\*=|\+=|-=)/.exec(n);if(!t)return n;var r=C(n)||0,a=parseFloat(e),o=parseFloat(n.replace(t[0],""));switch(t[0][0]){case"+":return a+o+r;case"-":return a-o+r;case"*":return a*o+r}}function L(n,e){if(i.col(n))return O(n);var t=C(n),r=t?n.substr(0,n.length-t.length):n;return e&&!/\s/g.test(n)?r+e:r}function j(n,e){return Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2))}function S(n){for(var e,t=n.points,r=0,a=0;a0&&(r+=j(e,o)),e=o}return r}function q(n){if(n.getTotalLength)return n.getTotalLength();switch(n.tagName.toLowerCase()){case"circle":return o=n,2*Math.PI*I(o,"r");case"rect":return 2*I(a=n,"width")+2*I(a,"height");case"line":return j({x:I(r=n,"x1"),y:I(r,"y1")},{x:I(r,"x2"),y:I(r,"y2")});case"polyline":return S(n);case"polygon":return t=(e=n).points,S(e)+j(t.getItem(t.numberOfItems-1),t.getItem(0))}var e,t,r,a,o}function $(n,e){var t=e||{},r=t.el||function(n){for(var e=n.parentNode;i.svg(e)&&(e=e.parentNode,i.svg(e.parentNode)););return e}(n),a=r.getBoundingClientRect(),o=I(r,"viewBox"),u=a.width,c=a.height,s=t.viewBox||(o?o.split(" "):[0,0,u,c]);return{el:r,viewBox:s,x:s[0]/1,y:s[1]/1,w:u/s[2],h:c/s[3]}}function X(n,e){function t(t){void 0===t&&(t=0);var r=e+t>=1?e+t:0;return n.el.getPointAtLength(r)}var r=$(n.el,n.svg),a=t(),o=t(-1),u=t(1);switch(n.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-o.y,u.x-o.x)/Math.PI}}function Y(n,e){var t=/-?\d*\.?\d+/g,r=L(i.pth(n)?n.totalLength:n,e)+"";return{original:r,numbers:r.match(t)?r.match(t).map(Number):[0],strings:i.str(n)||e?r.split(t):[]}}function Z(n){return m(n?y(i.arr(n)?n.map(b):b(n)):[],function(n,e,t){return t.indexOf(n)===e})}function Q(n){var e=Z(n);return e.map(function(n,t){return{target:n,id:t,total:e.length,transforms:{list:E(n)}}})}function V(n,e){var t=x(e);if(/^spring/.test(t.easing)&&(t.duration=s(t.easing)),i.arr(n)){var r=n.length;2===r&&!i.obj(n[0])?n={value:n}:i.fnc(e.duration)||(t.duration=e.duration/r)}var a=i.arr(n)?n:[n];return a.map(function(n,t){var r=i.obj(n)&&!i.pth(n)?n:{value:n};return i.und(r.delay)&&(r.delay=t?0:e.delay),i.und(r.endDelay)&&(r.endDelay=t===a.length-1?e.endDelay:0),r}).map(function(n){return k(n,t)})}function z(n,e){var t=[],r=e.keyframes;for(var a in r&&(e=k(function(n){for(var e=m(y(n.map(function(n){return Object.keys(n)})),function(n){return i.key(n)}).reduce(function(n,e){return n.indexOf(e)<0&&n.push(e),n},[]),t={},r=function(r){var a=e[r];t[a]=n.map(function(n){var e={};for(var t in n)i.key(t)?t==a&&(e.value=n[t]):e[t]=n[t];return e})},a=0;a-1&&(_.splice(o,1),t=_.length)}else a.tick(e);r++}n()}else U=cancelAnimationFrame(U)}return n}();function tn(t){void 0===t&&(t={});var r,o=0,u=0,i=0,c=0,s=null;function f(n){var e=window.Promise&&new Promise(function(n){return s=n});return n.finished=e,e}var l,d,p,h,v,g,y,b,M=(d=w(n,l=t),p=w(e,l),h=z(p,l),v=Q(l.targets),g=W(v,h),y=J(g,p),b=K,K++,k(d,{id:b,children:[],animatables:v,animations:g,duration:y.duration,delay:y.delay,endDelay:y.endDelay}));f(M);function x(){var n=M.direction;"alternate"!==n&&(M.direction="normal"!==n?"normal":"reverse"),M.reversed=!M.reversed,r.forEach(function(n){return n.reversed=M.reversed})}function O(n){return M.reversed?M.duration-n:n}function C(){o=0,u=O(M.currentTime)*(1/tn.speed)}function P(n,e){e&&e.seek(n-e.timelineOffset)}function I(n){for(var e=0,t=M.animations,r=t.length;e2||(b=Math.round(b*p)/p)),h.push(b)}var k=d.length;if(k){g=d[0];for(var O=0;O0&&(M.began=!0,B("begin"),B("loopBegin")),d<=t&&0!==M.currentTime&&I(0),(d>=l&&M.currentTime!==e||!e)&&I(e),d>t&&d=e&&(u=0,M.remaining&&!0!==M.remaining&&M.remaining--,M.remaining?(o=i,B("loopComplete"),B("loopBegin"),"alternate"===M.direction&&x()):(M.paused=!0,M.completed||(M.completed=!0,B("loopComplete"),B("complete"),!M.passThrough&&"Promise"in window&&(s(),f(M)))))}return M.reset=function(){var n=M.direction;M.passThrough=!1,M.currentTime=0,M.progress=0,M.paused=!0,M.began=!1,M.changeBegan=!1,M.completed=!1,M.changeCompleted=!1,M.reversePlayback=!1,M.reversed="reverse"===n,M.remaining=M.loop,r=M.children;for(var e=c=r.length;e--;)M.children[e].reset();(M.reversed&&!0!==M.loop||"alternate"===n&&1===M.loop)&&M.remaining++,I(0)},M.set=function(n,e){return R(n,e),M},M.tick=function(n){i=n,o||(o=i),D((i+(u-o))*tn.speed)},M.seek=function(n){D(O(n))},M.pause=function(){M.paused=!0,C()},M.play=function(){M.paused&&(M.completed&&M.reset(),M.paused=!1,_.push(M),C(),U||en())},M.reverse=function(){x(),C()},M.restart=function(){M.reset(),M.play()},M.reset(),M.autoplay&&M.play(),M}function rn(n,e){for(var t=e.length;t--;)M(n,e[t].animatable.target)&&e.splice(t,1)}return"undefined"!=typeof document&&document.addEventListener("visibilitychange",function(){document.hidden?(_.forEach(function(n){return n.pause()}),nn=_.slice(0),_=[]):nn.forEach(function(n){return n.play()})}),tn.version="3.0.1",tn.speed=1,tn.running=_,tn.remove=function(n){for(var e=Z(n),t=_.length;t--;){var r=_[t],a=r.animations,o=r.children;rn(e,a);for(var u=o.length;u--;){var i=o[u],c=i.animations;rn(e,c),c.length||i.children.length||o.splice(u,1)}a.length||o.length||r.pause()}},tn.get=N,tn.set=R,tn.convertPx=B,tn.path=function(n,e){var t=i.str(n)?g(n)[0]:n,r=e||100;return function(n){return{property:n,el:t,svg:$(t),totalLength:q(t)*(r/100)}}},tn.setDashoffset=function(n){var e=q(n);return n.setAttribute("stroke-dasharray",e),e},tn.stagger=function(n,e){void 0===e&&(e={});var t=e.direction||"normal",r=e.easing?v(e.easing):null,a=e.grid,o=e.axis,u=e.from||0,c="first"===u,s="center"===u,f="last"===u,l=i.arr(n),d=l?parseFloat(n[0]):parseFloat(n),p=l?parseFloat(n[1]):0,h=C(l?n[1]:n)||0,g=e.start||0+(l?d:0),m=[],y=0;return function(n,e,i){if(c&&(u=0),s&&(u=(i-1)/2),f&&(u=i-1),!m.length){for(var v=0;v-1&&_.splice(o,1);for(var s=0;s { - return (t === 0 || t === 1) ? t : - -a * Math.pow(2, 10 * (t - 1)) * Math.sin((((t - 1) - (p / (Math.PI * 2) * Math.asin(1 / a))) * (Math.PI * 2)) / p); - } -} - // Basic steps easing implementation https://developer.mozilla.org/fr/docs/Web/CSS/transition-timing-function function steps(steps = 10) { @@ -222,55 +211,42 @@ const bezier = (() => { const penner = (() => { - const names = ['Quad', 'Cubic', 'Quart', 'Quint', 'Sine', 'Expo', 'Circ', 'Back', 'Elastic']; - - // Approximated Penner equations http://matthewlein.com/ceaser/ - - const curves = { - In: [ - [0.550, 0.085, 0.680, 0.530], /* inQuad */ - [0.550, 0.055, 0.675, 0.190], /* inCubic */ - [0.895, 0.030, 0.685, 0.220], /* inQuart */ - [0.755, 0.050, 0.855, 0.060], /* inQuint */ - [0.470, 0.000, 0.745, 0.715], /* inSine */ - [0.950, 0.050, 0.795, 0.035], /* inExpo */ - [0.600, 0.040, 0.980, 0.335], /* inCirc */ - [0.600,-0.280, 0.735, 0.045], /* inBack */ - elastic /* inElastic */ - ], - Out: [ - [0.250, 0.460, 0.450, 0.940], /* outQuad */ - [0.215, 0.610, 0.355, 1.000], /* outCubic */ - [0.165, 0.840, 0.440, 1.000], /* outQuart */ - [0.230, 1.000, 0.320, 1.000], /* outQuint */ - [0.390, 0.575, 0.565, 1.000], /* outSine */ - [0.190, 1.000, 0.220, 1.000], /* outExpo */ - [0.075, 0.820, 0.165, 1.000], /* outCirc */ - [0.175, 0.885, 0.320, 1.275], /* outBack */ - (a, p) => t => 1 - elastic(a, p)(1 - t) /* outElastic */ - ], - InOut: [ - [0.455, 0.030, 0.515, 0.955], /* inOutQuad */ - [0.645, 0.045, 0.355, 1.000], /* inOutCubic */ - [0.770, 0.000, 0.175, 1.000], /* inOutQuart */ - [0.860, 0.000, 0.070, 1.000], /* inOutQuint */ - [0.445, 0.050, 0.550, 0.950], /* inOutSine */ - [1.000, 0.000, 0.000, 1.000], /* inOutExpo */ - [0.785, 0.135, 0.150, 0.860], /* inOutCirc */ - [0.680,-0.550, 0.265, 1.550], /* inOutBack */ - (a, p) => t => t < .5 ? elastic(a, p)(t * 2) / 2 : 1 - elastic(a, p)(t * -2 + 2) / 2 /* inOutElastic */ - ] + // Based on jQuery UI's implemenation of easing equations from Robert Penner (http://www.robertpenner.com/easing) + + const eases = { linear: () => t => t }; + + const functionEasings = { + Sine: () => t => 1 - Math.cos(t * Math.PI / 2), + Circ: () => t => 1 - Math.sqrt(1 - t * t), + Back: () => t => t * t * (3 * t - 2), + Bounce: () => t => { + let pow2, b = 4; + while (t < (( pow2 = Math.pow(2, --b)) - 1) / 11) {}; + return 1 / Math.pow(4, 3 - b) - 7.5625 * Math.pow(( pow2 * 3 - 2 ) / 22 - t, 2) + }, + Elastic: (amplitude = 1, period = .5) => { + const a = minMax(amplitude, 1, 10); + const p = minMax(period, .1, 2); + return t => { + return (t === 0 || t === 1) ? t : + -a * Math.pow(2, 10 * (t - 1)) * Math.sin((((t - 1) - (p / (Math.PI * 2) * Math.asin(1 / a))) * (Math.PI * 2)) / p); + } + } } - let eases = { - linear: [0.250, 0.250, 0.750, 0.750] - } + const baseEasings = ['Quad', 'Cubic', 'Quart', 'Quint', 'Expo']; - for (let coords in curves) { - curves[coords].forEach((ease, i) => { - eases['ease'+coords+names[i]] = ease; - }); - } + baseEasings.forEach((name, i) => { + functionEasings[name] = () => t => Math.pow(t, i + 2); + }); + + Object.keys(functionEasings).forEach(name => { + const easeIn = functionEasings[name]; + eases['easeIn' + name] = easeIn; + eases['easeOut' + name] = (a, b) => t => 1 - easeIn(a, b)(1 - t); + eases['easeInOut' + name] = (a, b) => t => t < 0.5 ? easeIn(a, b)(t * 2) / 2 : + 1 - easeIn(a, b)(t * -2 + 2) / 2; + }); return eases; @@ -285,7 +261,7 @@ function parseEasings(easing, duration) { case 'spring' : return spring(easing, duration); case 'cubicBezier' : return applyArguments(bezier, args); case 'steps' : return applyArguments(steps, args); - default : return is.fnc(ease) ? applyArguments(ease, args) : applyArguments(bezier, ease); + default : return applyArguments(ease, args); } } From 2d214342da5c5ef3f5109108a88ae80d9457eaab Mon Sep 17 00:00:00 2001 From: Julian Garnier Date: Tue, 23 Jul 2019 10:37:39 +0200 Subject: [PATCH 19/34] Update documentation --- documentation/examples/advanced-staggering-2.html | 2 +- documentation/examples/advanced-staggering.html | 2 +- documentation/examples/anime-stagger-demo.html | 2 +- documentation/examples/anime-staggering-demo.html | 13 ++++++++++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/documentation/examples/advanced-staggering-2.html b/documentation/examples/advanced-staggering-2.html index 90715b32..172c77ef 100644 --- a/documentation/examples/advanced-staggering-2.html +++ b/documentation/examples/advanced-staggering-2.html @@ -93,7 +93,7 @@ nextIndex = anime.random(0, numberOfElements); - anime.setValue('.cursor', { + anime.set('.cursor', { translateX: anime.stagger('-38px', {grid: [24, 11], from: index, axis: 'x'}), translateY: anime.stagger('-38px', {grid: [24, 11], from: index, axis: 'y'}) }); diff --git a/documentation/examples/advanced-staggering.html b/documentation/examples/advanced-staggering.html index 941b6a3a..cfa8d372 100644 --- a/documentation/examples/advanced-staggering.html +++ b/documentation/examples/advanced-staggering.html @@ -92,7 +92,7 @@ nextIndex = anime.random(0, numberOfElements); - anime.setValue('.cursor', { + anime.set('.cursor', { translateX: anime.stagger('-1rem', {grid: [16, 16], from: index, axis: 'x'}), translateY: anime.stagger('-1rem', {grid: [16, 16], from: index, axis: 'y'}) }); diff --git a/documentation/examples/anime-stagger-demo.html b/documentation/examples/anime-stagger-demo.html index ce348915..728c72d6 100644 --- a/documentation/examples/anime-stagger-demo.html +++ b/documentation/examples/anime-stagger-demo.html @@ -82,7 +82,7 @@ delay: anime.stagger(10, {from: 'center'}) }) .add({ - scale: anime.stagger([2.5, 1], {from: 'center', easing: 'easeInSine'}), + scale: anime.stagger([2.5, 1], {from: 'center', easing: 'easeInOutCirc'}), translateX: anime.stagger([-200, 200]), translateY: anime.stagger([-200, 200]), rotate: 0, diff --git a/documentation/examples/anime-staggering-demo.html b/documentation/examples/anime-staggering-demo.html index 6c6046a4..bec0e87a 100644 --- a/documentation/examples/anime-staggering-demo.html +++ b/documentation/examples/anime-staggering-demo.html @@ -126,22 +126,29 @@ anime({ targets: '.easing-visualizer div', + translateZ: 0, translateY: (() => { const keyframes = []; + // keyframes.push({ value: 0, delay: stagger(.125) }); + // keyframes.push({ value: stagger([0, -400], {easing: 'steps(10)'}), delay: stagger(.125) }); 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; })(), + // translateY: { + // value: stagger([0, -400], {easing:'easeInOutSine'}), + // delay: stagger(.125) + // }, easing: 'easeInOutSine', - duration: 16000, + duration: 6000, loop: true }); + console.log(anime.penner); + From c00b4611bbab3ad13487c9b2495528bc2357d692 Mon Sep 17 00:00:00 2001 From: Julian Garnier Date: Tue, 23 Jul 2019 15:32:13 +0200 Subject: [PATCH 20/34] Fix wrong unit parsing when unit contains spaces #502 --- .../examples/anime-DOM-stress-test.html | 11 +- .../examples/anime-complex-properties.html | 40 +- documentation/examples/anime-stagger-2.html | 299 ----------- documentation/examples/anime-stagger-3.html | 431 --------------- documentation/examples/anime-stagger-4.html | 500 ------------------ .../{anime-stager.html => anime-stagger.html} | 0 .../examples/anime-states-system.html | 115 ---- lib/anime.es.js | 4 +- lib/anime.js | 4 +- lib/anime.min.js | 2 +- src/index.js | 4 +- 11 files changed, 42 insertions(+), 1368 deletions(-) delete mode 100644 documentation/examples/anime-stagger-2.html delete mode 100644 documentation/examples/anime-stagger-3.html delete mode 100644 documentation/examples/anime-stagger-4.html rename documentation/examples/{anime-stager.html => anime-stagger.html} (100%) delete mode 100644 documentation/examples/anime-states-system.html diff --git a/documentation/examples/anime-DOM-stress-test.html b/documentation/examples/anime-DOM-stress-test.html index 116b88ea..c2f30e60 100644 --- a/documentation/examples/anime-DOM-stress-test.html +++ b/documentation/examples/anime-DOM-stress-test.html @@ -45,23 +45,22 @@ function createEl(i) { var el = document.createElement('div'); var hue = Math.round(360 / numberOfEls * i); - var angle = i; el.classList.add('el'); //el.style.border = '5px solid hsl(' + hue + ', 50%, 50%)'; el.style.backgroundColor = 'hsl(' + hue + ', 50%, 50%)'; wrapperEl.appendChild(el); anime({ targets: el, - translateX: Math.sin(angle) * distance + 'rem', - translateY: Math.cos(angle) * distance + 'rem', + translateX: Math.sin(i) * distance + 'rem', + translateY: Math.cos(i) * distance + 'rem', scale: [ - {value: [0, 1]}, - {value: 0} + {value: [.1, 2]}, + {value: .1} ], easing: 'easeInOutSine', loop: true, duration: duration, - startTime: i * (duration / numberOfEls) + delay: i * (duration / numberOfEls) }); }; diff --git a/documentation/examples/anime-complex-properties.html b/documentation/examples/anime-complex-properties.html index 37ea8b04..3467b289 100644 --- a/documentation/examples/anime-complex-properties.html +++ b/documentation/examples/anime-complex-properties.html @@ -14,7 +14,7 @@ - + @@ -22,6 +22,7 @@ -
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -60,7 +65,8 @@ -
+
+
- diff --git a/documentation/examples/anime-stagger-3.html b/documentation/examples/anime-stagger-3.html deleted file mode 100644 index ada1ba51..00000000 --- a/documentation/examples/anime-stagger-3.html +++ /dev/null @@ -1,431 +0,0 @@ - - - - stagger | anime.js - - - - - - - - - - - - - - - - - - -
- -
- -
-

Normal

-
-
- -
-

Normal reversed

-
-
- -
-

From last

-
-
- -
-

From last reversed

-
-
- -
-

From middle

-
-
- -
-

From middle reversed

-
-
- -
-

From index

-
-
- -
-

From index reversed

-
-
- -
-

Range

-
-
- -
-

Range reversed

-
-
- -
-

Range from last

-
-
- -
-

Range from last reversed

-
-
- -
-

Range from middle

-
-
- -
-

Range from middle reversed

-
-
- -
- - - - diff --git a/documentation/examples/anime-stagger-4.html b/documentation/examples/anime-stagger-4.html deleted file mode 100644 index 78c19b81..00000000 --- a/documentation/examples/anime-stagger-4.html +++ /dev/null @@ -1,500 +0,0 @@ - - - - stagger | anime.js - - - - - - - - - - - - - - - - - - -
- -
- -
-

Normal

-
-
- -
-

Normal reversed

-
-
- -
-

From last

-
-
- -
-

From last reversed

-
-
- -
-

From middle

-
-
- -
-

From middle reversed

-
-
- -
-

From index

-
-
- -
-

From index reversed

-
-
- -
-

Range

-
-
- -
-

Range reversed

-
-
- -
-

Range from last

-
-
- -
-

Range from last reversed

-
-
- -
-

Range from middle

-
-
- -
-

Range from middle reversed

-
-
- -
-

Easing

-
-
- -
-

Easing reversed

-
-
- -
-

Coordinates

-
-
-
-
-
-
- -
-

Coordinates reversed

-
-
-
-
-
-
- -
- - - - diff --git a/documentation/examples/anime-stager.html b/documentation/examples/anime-stagger.html similarity index 100% rename from documentation/examples/anime-stager.html rename to documentation/examples/anime-stagger.html diff --git a/documentation/examples/anime-states-system.html b/documentation/examples/anime-states-system.html deleted file mode 100644 index b9fe5734..00000000 --- a/documentation/examples/anime-states-system.html +++ /dev/null @@ -1,115 +0,0 @@ - - - - Anime states system | anime.js - - - - - - - - - - - - - - - - - - -
-
- - - - - - diff --git a/lib/anime.es.js b/lib/anime.es.js index 9c52d3b1..c641ad37 100644 --- a/lib/anime.es.js +++ b/lib/anime.es.js @@ -489,9 +489,11 @@ function getRelativeValue(to, from) { function validateValue(val, unit) { if (is.col(val)) { return colorToRgb(val); } + if (/\s/g.test(val)) { return val; } var originalUnit = getUnit(val); var unitLess = originalUnit ? val.substr(0, val.length - originalUnit.length) : val; - return unit && !/\s/g.test(val) ? unitLess + unit : unitLess; + if (unit) { return unitLess + unit; } + return unitLess; } // getTotalLength() equivalent for circle, rect, polyline, polygon and line shapes diff --git a/lib/anime.js b/lib/anime.js index f48317e5..67d98057 100644 --- a/lib/anime.js +++ b/lib/anime.js @@ -491,9 +491,11 @@ function getRelativeValue(to, from) { function validateValue(val, unit) { if (is.col(val)) { return colorToRgb(val); } + if (/\s/g.test(val)) { return val; } var originalUnit = getUnit(val); var unitLess = originalUnit ? val.substr(0, val.length - originalUnit.length) : val; - return unit && !/\s/g.test(val) ? unitLess + unit : unitLess; + if (unit) { return unitLess + unit; } + return unitLess; } // getTotalLength() equivalent for circle, rect, polyline, polygon and line shapes diff --git a/lib/anime.min.js b/lib/anime.min.js index 0f84643a..fc84a898 100644 --- a/lib/anime.min.js +++ b/lib/anime.min.js @@ -5,4 +5,4 @@ * animejs.com */ -!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):n.anime=e()}(this,function(){"use strict";var n={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0},e={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(n,e,t){return Math.min(Math.max(n,e),t)}function o(n,e){return n.indexOf(e)>-1}function u(n,e){return n.apply(null,e)}var i={arr:function(n){return Array.isArray(n)},obj:function(n){return o(Object.prototype.toString.call(n),"Object")},pth:function(n){return i.obj(n)&&n.hasOwnProperty("totalLength")},svg:function(n){return n instanceof SVGElement},inp:function(n){return n instanceof HTMLInputElement},dom:function(n){return n.nodeType||i.svg(n)},str:function(n){return"string"==typeof n},fnc:function(n){return"function"==typeof n},und:function(n){return void 0===n},hex:function(n){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(n)},rgb:function(n){return/^rgb/.test(n)},hsl:function(n){return/^hsl/.test(n)},col:function(n){return i.hex(n)||i.rgb(n)||i.hsl(n)},key:function(t){return!n.hasOwnProperty(t)&&!e.hasOwnProperty(t)&&"targets"!==t&&"keyframes"!==t}};function c(n){var e=/\(([^)]+)\)/.exec(n);return e?e[1].split(",").map(function(n){return parseFloat(n)}):[]}function s(n,e){var t=c(n),o=a(i.und(t[0])?1:t[0],.1,100),u=a(i.und(t[1])?100:t[1],.1,100),s=a(i.und(t[2])?10:t[2],.1,100),f=a(i.und(t[3])?0:t[3],.1,100),l=Math.sqrt(u/o),d=s/(2*Math.sqrt(u*o)),p=d<1?l*Math.sqrt(1-d*d):0,h=1,v=d<1?(d*l-f)/p:-f+l;function g(n){var t=e?e*n/1e3:n;return t=d<1?Math.exp(-t*d*l)*(h*Math.cos(p*t)+v*Math.sin(p*t)):(h+v*t)*Math.exp(-t*l),0===n||1===n?n:1-t}return e?g:function(){var e=r.springs[n];if(e)return e;for(var t=0,a=0;;)if(1===g(t+=1/6)){if(++a>=16)break}else a=0;var o=t*(1/6)*1e3;return r.springs[n]=o,o}}function f(n){return void 0===n&&(n=10),function(e){return Math.round(e*n)*(1/n)}}var l,d,p=function(){var n=11,e=1/(n-1);function t(n,e){return 1-3*e+3*n}function r(n,e){return 3*e-6*n}function a(n){return 3*n}function o(n,e,o){return((t(e,o)*n+r(e,o))*n+a(e))*n}function u(n,e,o){return 3*t(e,o)*n*n+2*r(e,o)*n+a(e)}return function(t,r,a,i){if(0<=t&&t<=1&&0<=a&&a<=1){var c=new Float32Array(n);if(t!==r||a!==i)for(var s=0;s=.001?function(n,e,t,r){for(var a=0;a<4;++a){var i=u(e,t,r);if(0===i)return e;e-=(o(e,t,r)-n)/i}return e}(r,l,t,a):0===d?l:function(n,e,t,r,a){for(var u,i,c=0;(u=o(i=e+(t-e)/2,r,a)-n)>0?t=i:e=i,Math.abs(u)>1e-7&&++c<10;);return i}(r,i,i+e,t,a)}}}(),h=(l={linear:function(){return function(n){return n}}},d={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var e,t=4;n<((e=Math.pow(2,--t))-1)/11;);return 1/Math.pow(4,3-t)-7.5625*Math.pow((3*e-2)/22-n,2)}},Elastic:function(n,e){void 0===n&&(n=1),void 0===e&&(e=.5);var t=a(n,1,10),r=a(e,.1,2);return function(n){return 0===n||1===n?n:-t*Math.pow(2,10*(n-1))*Math.sin((n-1-r/(2*Math.PI)*Math.asin(1/t))*(2*Math.PI)/r)}}},["Quad","Cubic","Quart","Quint","Expo"].forEach(function(n,e){d[n]=function(){return function(n){return Math.pow(n,e+2)}}}),Object.keys(d).forEach(function(n){var e=d[n];l["easeIn"+n]=e,l["easeOut"+n]=function(n,t){return function(r){return 1-e(n,t)(1-r)}},l["easeInOut"+n]=function(n,t){return function(r){return r<.5?e(n,t)(2*r)/2:1-e(n,t)(-2*r+2)/2}}}),l);function v(n,e){if(i.fnc(n))return n;var t=n.split("(")[0],r=h[t],a=c(n);switch(t){case"spring":return s(n,e);case"cubicBezier":return u(p,a);case"steps":return u(f,a);default:return u(r,a)}}function g(n){try{return document.querySelectorAll(n)}catch(n){return}}function m(n,e){for(var t=n.length,r=arguments.length>=2?arguments[1]:void 0,a=[],o=0;o1&&(t-=1),t<1/6?n+6*(e-n)*t:t<.5?e:t<2/3?n+(e-n)*(2/3-t)*6:n}if(0==u)e=t=r=i;else{var f=i<.5?i*(1+u):i+u-i*u,l=2*i-f;e=s(l,f,o+1/3),t=s(l,f,o),r=s(l,f,o-1/3)}return"rgba("+255*e+","+255*t+","+255*r+","+c+")"}(n):void 0;var e,t,r,a}function C(n){var e=/([\+\-]?[0-9#\.]+)(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(n);if(e)return e[2]}function P(n,e){return i.fnc(n)?n(e.target,e.id,e.total):n}function I(n,e){return n.getAttribute(e)}function B(n,e,t){if(M([t,"deg","rad","turn"],C(e)))return e;var a=r.CSS[e+t];if(!i.und(a))return a;var o=document.createElement(n.tagName),u=n.parentNode&&n.parentNode!==document?n.parentNode:document.body;u.appendChild(o),o.style.position="absolute",o.style.width=100+t;var c=100/o.offsetWidth;u.removeChild(o);var s=c*parseFloat(e);return r.CSS[e+t]=s,s}function D(n,e,t){if(e in n.style){var r=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),a=n.style[e]||getComputedStyle(n).getPropertyValue(r)||"0";return t?B(n,a,t):a}}function T(n,e){return i.dom(n)&&!i.inp(n)&&(I(n,e)||i.svg(n)&&n[e])?"attribute":i.dom(n)&&M(t,e)?"transform":i.dom(n)&&"transform"!==e&&D(n,e)?"css":null!=n[e]?"object":void 0}function E(n){if(i.dom(n)){for(var e,t=n.style.transform||"",r=/(\w+)\(([^)]*)\)/g,a=new Map;e=r.exec(t);)a.set(e[1],e[2]);return a}}function F(n,e,t,r){var a,u=o(e,"scale")?1:0+(o(a=e,"translate")||"perspective"===a?"px":o(a,"rotate")||o(a,"skew")?"deg":void 0),i=E(n).get(e)||u;return t&&(t.transforms.list.set(e,i),t.transforms.last=e),r?B(n,i,r):i}function N(n,e,t,r){switch(T(n,e)){case"transform":return F(n,e,r,t);case"css":return D(n,e,t);case"attribute":return I(n,e);default:return n[e]||0}}function A(n,e){var t=/^(\*=|\+=|-=)/.exec(n);if(!t)return n;var r=C(n)||0,a=parseFloat(e),o=parseFloat(n.replace(t[0],""));switch(t[0][0]){case"+":return a+o+r;case"-":return a-o+r;case"*":return a*o+r}}function L(n,e){if(i.col(n))return O(n);var t=C(n),r=t?n.substr(0,n.length-t.length):n;return e&&!/\s/g.test(n)?r+e:r}function j(n,e){return Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2))}function S(n){for(var e,t=n.points,r=0,a=0;a0&&(r+=j(e,o)),e=o}return r}function q(n){if(n.getTotalLength)return n.getTotalLength();switch(n.tagName.toLowerCase()){case"circle":return o=n,2*Math.PI*I(o,"r");case"rect":return 2*I(a=n,"width")+2*I(a,"height");case"line":return j({x:I(r=n,"x1"),y:I(r,"y1")},{x:I(r,"x2"),y:I(r,"y2")});case"polyline":return S(n);case"polygon":return t=(e=n).points,S(e)+j(t.getItem(t.numberOfItems-1),t.getItem(0))}var e,t,r,a,o}function $(n,e){var t=e||{},r=t.el||function(n){for(var e=n.parentNode;i.svg(e)&&(e=e.parentNode,i.svg(e.parentNode)););return e}(n),a=r.getBoundingClientRect(),o=I(r,"viewBox"),u=a.width,c=a.height,s=t.viewBox||(o?o.split(" "):[0,0,u,c]);return{el:r,viewBox:s,x:s[0]/1,y:s[1]/1,w:u/s[2],h:c/s[3]}}function X(n,e){function t(t){void 0===t&&(t=0);var r=e+t>=1?e+t:0;return n.el.getPointAtLength(r)}var r=$(n.el,n.svg),a=t(),o=t(-1),u=t(1);switch(n.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-o.y,u.x-o.x)/Math.PI}}function Y(n,e){var t=/-?\d*\.?\d+/g,r=L(i.pth(n)?n.totalLength:n,e)+"";return{original:r,numbers:r.match(t)?r.match(t).map(Number):[0],strings:i.str(n)||e?r.split(t):[]}}function Z(n){return m(n?y(i.arr(n)?n.map(b):b(n)):[],function(n,e,t){return t.indexOf(n)===e})}function Q(n){var e=Z(n);return e.map(function(n,t){return{target:n,id:t,total:e.length,transforms:{list:E(n)}}})}function V(n,e){var t=x(e);if(/^spring/.test(t.easing)&&(t.duration=s(t.easing)),i.arr(n)){var r=n.length;2===r&&!i.obj(n[0])?n={value:n}:i.fnc(e.duration)||(t.duration=e.duration/r)}var a=i.arr(n)?n:[n];return a.map(function(n,t){var r=i.obj(n)&&!i.pth(n)?n:{value:n};return i.und(r.delay)&&(r.delay=t?0:e.delay),i.und(r.endDelay)&&(r.endDelay=t===a.length-1?e.endDelay:0),r}).map(function(n){return k(n,t)})}function z(n,e){var t=[],r=e.keyframes;for(var a in r&&(e=k(function(n){for(var e=m(y(n.map(function(n){return Object.keys(n)})),function(n){return i.key(n)}).reduce(function(n,e){return n.indexOf(e)<0&&n.push(e),n},[]),t={},r=function(r){var a=e[r];t[a]=n.map(function(n){var e={};for(var t in n)i.key(t)?t==a&&(e.value=n[t]):e[t]=n[t];return e})},a=0;a-1&&(_.splice(o,1),t=_.length)}else a.tick(e);r++}n()}else U=cancelAnimationFrame(U)}return n}();function tn(t){void 0===t&&(t={});var r,o=0,u=0,i=0,c=0,s=null;function f(n){var e=window.Promise&&new Promise(function(n){return s=n});return n.finished=e,e}var l,d,p,h,v,g,y,b,M=(d=w(n,l=t),p=w(e,l),h=z(p,l),v=Q(l.targets),g=W(v,h),y=J(g,p),b=K,K++,k(d,{id:b,children:[],animatables:v,animations:g,duration:y.duration,delay:y.delay,endDelay:y.endDelay}));f(M);function x(){var n=M.direction;"alternate"!==n&&(M.direction="normal"!==n?"normal":"reverse"),M.reversed=!M.reversed,r.forEach(function(n){return n.reversed=M.reversed})}function O(n){return M.reversed?M.duration-n:n}function C(){o=0,u=O(M.currentTime)*(1/tn.speed)}function P(n,e){e&&e.seek(n-e.timelineOffset)}function I(n){for(var e=0,t=M.animations,r=t.length;e2||(b=Math.round(b*p)/p)),h.push(b)}var k=d.length;if(k){g=d[0];for(var O=0;O0&&(M.began=!0,B("begin"),B("loopBegin")),d<=t&&0!==M.currentTime&&I(0),(d>=l&&M.currentTime!==e||!e)&&I(e),d>t&&d=e&&(u=0,M.remaining&&!0!==M.remaining&&M.remaining--,M.remaining?(o=i,B("loopComplete"),B("loopBegin"),"alternate"===M.direction&&x()):(M.paused=!0,M.completed||(M.completed=!0,B("loopComplete"),B("complete"),!M.passThrough&&"Promise"in window&&(s(),f(M)))))}return M.reset=function(){var n=M.direction;M.passThrough=!1,M.currentTime=0,M.progress=0,M.paused=!0,M.began=!1,M.changeBegan=!1,M.completed=!1,M.changeCompleted=!1,M.reversePlayback=!1,M.reversed="reverse"===n,M.remaining=M.loop,r=M.children;for(var e=c=r.length;e--;)M.children[e].reset();(M.reversed&&!0!==M.loop||"alternate"===n&&1===M.loop)&&M.remaining++,I(0)},M.set=function(n,e){return R(n,e),M},M.tick=function(n){i=n,o||(o=i),D((i+(u-o))*tn.speed)},M.seek=function(n){D(O(n))},M.pause=function(){M.paused=!0,C()},M.play=function(){M.paused&&(M.completed&&M.reset(),M.paused=!1,_.push(M),C(),U||en())},M.reverse=function(){x(),C()},M.restart=function(){M.reset(),M.play()},M.reset(),M.autoplay&&M.play(),M}function rn(n,e){for(var t=e.length;t--;)M(n,e[t].animatable.target)&&e.splice(t,1)}return"undefined"!=typeof document&&document.addEventListener("visibilitychange",function(){document.hidden?(_.forEach(function(n){return n.pause()}),nn=_.slice(0),_=[]):nn.forEach(function(n){return n.play()})}),tn.version="3.0.1",tn.speed=1,tn.running=_,tn.remove=function(n){for(var e=Z(n),t=_.length;t--;){var r=_[t],a=r.animations,o=r.children;rn(e,a);for(var u=o.length;u--;){var i=o[u],c=i.animations;rn(e,c),c.length||i.children.length||o.splice(u,1)}a.length||o.length||r.pause()}},tn.get=N,tn.set=R,tn.convertPx=B,tn.path=function(n,e){var t=i.str(n)?g(n)[0]:n,r=e||100;return function(n){return{property:n,el:t,svg:$(t),totalLength:q(t)*(r/100)}}},tn.setDashoffset=function(n){var e=q(n);return n.setAttribute("stroke-dasharray",e),e},tn.stagger=function(n,e){void 0===e&&(e={});var t=e.direction||"normal",r=e.easing?v(e.easing):null,a=e.grid,o=e.axis,u=e.from||0,c="first"===u,s="center"===u,f="last"===u,l=i.arr(n),d=l?parseFloat(n[0]):parseFloat(n),p=l?parseFloat(n[1]):0,h=C(l?n[1]:n)||0,g=e.start||0+(l?d:0),m=[],y=0;return function(n,e,i){if(c&&(u=0),s&&(u=(i-1)/2),f&&(u=i-1),!m.length){for(var v=0;v-1&&_.splice(o,1);for(var s=0;s-1}function o(n,e){return n.apply(null,e)}var i={arr:function(n){return Array.isArray(n)},obj:function(n){return u(Object.prototype.toString.call(n),"Object")},pth:function(n){return i.obj(n)&&n.hasOwnProperty("totalLength")},svg:function(n){return n instanceof SVGElement},inp:function(n){return n instanceof HTMLInputElement},dom:function(n){return n.nodeType||i.svg(n)},str:function(n){return"string"==typeof n},fnc:function(n){return"function"==typeof n},und:function(n){return void 0===n},hex:function(n){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(n)},rgb:function(n){return/^rgb/.test(n)},hsl:function(n){return/^hsl/.test(n)},col:function(n){return i.hex(n)||i.rgb(n)||i.hsl(n)},key:function(t){return!n.hasOwnProperty(t)&&!e.hasOwnProperty(t)&&"targets"!==t&&"keyframes"!==t}};function c(n){var e=/\(([^)]+)\)/.exec(n);return e?e[1].split(",").map(function(n){return parseFloat(n)}):[]}function s(n,e){var t=c(n),u=a(i.und(t[0])?1:t[0],.1,100),o=a(i.und(t[1])?100:t[1],.1,100),s=a(i.und(t[2])?10:t[2],.1,100),f=a(i.und(t[3])?0:t[3],.1,100),l=Math.sqrt(o/u),d=s/(2*Math.sqrt(o*u)),p=d<1?l*Math.sqrt(1-d*d):0,h=1,v=d<1?(d*l-f)/p:-f+l;function g(n){var t=e?e*n/1e3:n;return t=d<1?Math.exp(-t*d*l)*(h*Math.cos(p*t)+v*Math.sin(p*t)):(h+v*t)*Math.exp(-t*l),0===n||1===n?n:1-t}return e?g:function(){var e=r.springs[n];if(e)return e;for(var t=0,a=0;;)if(1===g(t+=1/6)){if(++a>=16)break}else a=0;var u=t*(1/6)*1e3;return r.springs[n]=u,u}}function f(n){return void 0===n&&(n=10),function(e){return Math.round(e*n)*(1/n)}}var l,d,p=function(){var n=11,e=1/(n-1);function t(n,e){return 1-3*e+3*n}function r(n,e){return 3*e-6*n}function a(n){return 3*n}function u(n,e,u){return((t(e,u)*n+r(e,u))*n+a(e))*n}function o(n,e,u){return 3*t(e,u)*n*n+2*r(e,u)*n+a(e)}return function(t,r,a,i){if(0<=t&&t<=1&&0<=a&&a<=1){var c=new Float32Array(n);if(t!==r||a!==i)for(var s=0;s=.001?function(n,e,t,r){for(var a=0;a<4;++a){var i=o(e,t,r);if(0===i)return e;e-=(u(e,t,r)-n)/i}return e}(r,l,t,a):0===d?l:function(n,e,t,r,a){for(var o,i,c=0;(o=u(i=e+(t-e)/2,r,a)-n)>0?t=i:e=i,Math.abs(o)>1e-7&&++c<10;);return i}(r,i,i+e,t,a)}}}(),h=(l={linear:function(){return function(n){return n}}},d={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var e,t=4;n<((e=Math.pow(2,--t))-1)/11;);return 1/Math.pow(4,3-t)-7.5625*Math.pow((3*e-2)/22-n,2)}},Elastic:function(n,e){void 0===n&&(n=1),void 0===e&&(e=.5);var t=a(n,1,10),r=a(e,.1,2);return function(n){return 0===n||1===n?n:-t*Math.pow(2,10*(n-1))*Math.sin((n-1-r/(2*Math.PI)*Math.asin(1/t))*(2*Math.PI)/r)}}},["Quad","Cubic","Quart","Quint","Expo"].forEach(function(n,e){d[n]=function(){return function(n){return Math.pow(n,e+2)}}}),Object.keys(d).forEach(function(n){var e=d[n];l["easeIn"+n]=e,l["easeOut"+n]=function(n,t){return function(r){return 1-e(n,t)(1-r)}},l["easeInOut"+n]=function(n,t){return function(r){return r<.5?e(n,t)(2*r)/2:1-e(n,t)(-2*r+2)/2}}}),l);function v(n,e){if(i.fnc(n))return n;var t=n.split("(")[0],r=h[t],a=c(n);switch(t){case"spring":return s(n,e);case"cubicBezier":return o(p,a);case"steps":return o(f,a);default:return o(r,a)}}function g(n){try{return document.querySelectorAll(n)}catch(n){return}}function m(n,e){for(var t=n.length,r=arguments.length>=2?arguments[1]:void 0,a=[],u=0;u1&&(t-=1),t<1/6?n+6*(e-n)*t:t<.5?e:t<2/3?n+(e-n)*(2/3-t)*6:n}if(0==o)e=t=r=i;else{var f=i<.5?i*(1+o):i+o-i*o,l=2*i-f;e=s(l,f,u+1/3),t=s(l,f,u),r=s(l,f,u-1/3)}return"rgba("+255*e+","+255*t+","+255*r+","+c+")"}(n):void 0;var e,t,r,a}function C(n){var e=/([\+\-]?[0-9#\.]+)(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(n);if(e)return e[2]}function P(n,e){return i.fnc(n)?n(e.target,e.id,e.total):n}function I(n,e){return n.getAttribute(e)}function B(n,e,t){if(M([t,"deg","rad","turn"],C(e)))return e;var a=r.CSS[e+t];if(!i.und(a))return a;var u=document.createElement(n.tagName),o=n.parentNode&&n.parentNode!==document?n.parentNode:document.body;o.appendChild(u),u.style.position="absolute",u.style.width=100+t;var c=100/u.offsetWidth;o.removeChild(u);var s=c*parseFloat(e);return r.CSS[e+t]=s,s}function D(n,e,t){if(e in n.style){var r=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),a=n.style[e]||getComputedStyle(n).getPropertyValue(r)||"0";return t?B(n,a,t):a}}function T(n,e){return i.dom(n)&&!i.inp(n)&&(I(n,e)||i.svg(n)&&n[e])?"attribute":i.dom(n)&&M(t,e)?"transform":i.dom(n)&&"transform"!==e&&D(n,e)?"css":null!=n[e]?"object":void 0}function E(n){if(i.dom(n)){for(var e,t=n.style.transform||"",r=/(\w+)\(([^)]*)\)/g,a=new Map;e=r.exec(t);)a.set(e[1],e[2]);return a}}function F(n,e,t,r){var a,o=u(e,"scale")?1:0+(u(a=e,"translate")||"perspective"===a?"px":u(a,"rotate")||u(a,"skew")?"deg":void 0),i=E(n).get(e)||o;return t&&(t.transforms.list.set(e,i),t.transforms.last=e),r?B(n,i,r):i}function N(n,e,t,r){switch(T(n,e)){case"transform":return F(n,e,r,t);case"css":return D(n,e,t);case"attribute":return I(n,e);default:return n[e]||0}}function A(n,e){var t=/^(\*=|\+=|-=)/.exec(n);if(!t)return n;var r=C(n)||0,a=parseFloat(e),u=parseFloat(n.replace(t[0],""));switch(t[0][0]){case"+":return a+u+r;case"-":return a-u+r;case"*":return a*u+r}}function L(n,e){if(i.col(n))return O(n);if(/\s/g.test(n))return n;var t=C(n),r=t?n.substr(0,n.length-t.length):n;return e?r+e:r}function j(n,e){return Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2))}function S(n){for(var e,t=n.points,r=0,a=0;a0&&(r+=j(e,u)),e=u}return r}function q(n){if(n.getTotalLength)return n.getTotalLength();switch(n.tagName.toLowerCase()){case"circle":return u=n,2*Math.PI*I(u,"r");case"rect":return 2*I(a=n,"width")+2*I(a,"height");case"line":return j({x:I(r=n,"x1"),y:I(r,"y1")},{x:I(r,"x2"),y:I(r,"y2")});case"polyline":return S(n);case"polygon":return t=(e=n).points,S(e)+j(t.getItem(t.numberOfItems-1),t.getItem(0))}var e,t,r,a,u}function $(n,e){var t=e||{},r=t.el||function(n){for(var e=n.parentNode;i.svg(e)&&(e=e.parentNode,i.svg(e.parentNode)););return e}(n),a=r.getBoundingClientRect(),u=I(r,"viewBox"),o=a.width,c=a.height,s=t.viewBox||(u?u.split(" "):[0,0,o,c]);return{el:r,viewBox:s,x:s[0]/1,y:s[1]/1,w:o/s[2],h:c/s[3]}}function X(n,e){function t(t){void 0===t&&(t=0);var r=e+t>=1?e+t:0;return n.el.getPointAtLength(r)}var r=$(n.el,n.svg),a=t(),u=t(-1),o=t(1);switch(n.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-u.y,o.x-u.x)/Math.PI}}function Y(n,e){var t=/-?\d*\.?\d+/g,r=L(i.pth(n)?n.totalLength:n,e)+"";return{original:r,numbers:r.match(t)?r.match(t).map(Number):[0],strings:i.str(n)||e?r.split(t):[]}}function Z(n){return m(n?y(i.arr(n)?n.map(b):b(n)):[],function(n,e,t){return t.indexOf(n)===e})}function Q(n){var e=Z(n);return e.map(function(n,t){return{target:n,id:t,total:e.length,transforms:{list:E(n)}}})}function V(n,e){var t=x(e);if(/^spring/.test(t.easing)&&(t.duration=s(t.easing)),i.arr(n)){var r=n.length;2===r&&!i.obj(n[0])?n={value:n}:i.fnc(e.duration)||(t.duration=e.duration/r)}var a=i.arr(n)?n:[n];return a.map(function(n,t){var r=i.obj(n)&&!i.pth(n)?n:{value:n};return i.und(r.delay)&&(r.delay=t?0:e.delay),i.und(r.endDelay)&&(r.endDelay=t===a.length-1?e.endDelay:0),r}).map(function(n){return k(n,t)})}function z(n,e){var t=[],r=e.keyframes;for(var a in r&&(e=k(function(n){for(var e=m(y(n.map(function(n){return Object.keys(n)})),function(n){return i.key(n)}).reduce(function(n,e){return n.indexOf(e)<0&&n.push(e),n},[]),t={},r=function(r){var a=e[r];t[a]=n.map(function(n){var e={};for(var t in n)i.key(t)?t==a&&(e.value=n[t]):e[t]=n[t];return e})},a=0;a-1&&(_.splice(u,1),t=_.length)}else a.tick(e);r++}n()}else U=cancelAnimationFrame(U)}return n}();function tn(t){void 0===t&&(t={});var r,u=0,o=0,i=0,c=0,s=null;function f(n){var e=window.Promise&&new Promise(function(n){return s=n});return n.finished=e,e}var l,d,p,h,v,g,y,b,M=(d=w(n,l=t),p=w(e,l),h=z(p,l),v=Q(l.targets),g=W(v,h),y=J(g,p),b=K,K++,k(d,{id:b,children:[],animatables:v,animations:g,duration:y.duration,delay:y.delay,endDelay:y.endDelay}));f(M);function x(){var n=M.direction;"alternate"!==n&&(M.direction="normal"!==n?"normal":"reverse"),M.reversed=!M.reversed,r.forEach(function(n){return n.reversed=M.reversed})}function O(n){return M.reversed?M.duration-n:n}function C(){u=0,o=O(M.currentTime)*(1/tn.speed)}function P(n,e){e&&e.seek(n-e.timelineOffset)}function I(n){for(var e=0,t=M.animations,r=t.length;e2||(b=Math.round(b*p)/p)),h.push(b)}var k=d.length;if(k){g=d[0];for(var O=0;O0&&(M.began=!0,B("begin"),B("loopBegin")),d<=t&&0!==M.currentTime&&I(0),(d>=l&&M.currentTime!==e||!e)&&I(e),d>t&&d=e&&(o=0,M.remaining&&!0!==M.remaining&&M.remaining--,M.remaining?(u=i,B("loopComplete"),B("loopBegin"),"alternate"===M.direction&&x()):(M.paused=!0,M.completed||(M.completed=!0,B("loopComplete"),B("complete"),!M.passThrough&&"Promise"in window&&(s(),f(M)))))}return M.reset=function(){var n=M.direction;M.passThrough=!1,M.currentTime=0,M.progress=0,M.paused=!0,M.began=!1,M.changeBegan=!1,M.completed=!1,M.changeCompleted=!1,M.reversePlayback=!1,M.reversed="reverse"===n,M.remaining=M.loop,r=M.children;for(var e=c=r.length;e--;)M.children[e].reset();(M.reversed&&!0!==M.loop||"alternate"===n&&1===M.loop)&&M.remaining++,I(0)},M.set=function(n,e){return R(n,e),M},M.tick=function(n){i=n,u||(u=i),D((i+(o-u))*tn.speed)},M.seek=function(n){D(O(n))},M.pause=function(){M.paused=!0,C()},M.play=function(){M.paused&&(M.completed&&M.reset(),M.paused=!1,_.push(M),C(),U||en())},M.reverse=function(){x(),C()},M.restart=function(){M.reset(),M.play()},M.reset(),M.autoplay&&M.play(),M}function rn(n,e){for(var t=e.length;t--;)M(n,e[t].animatable.target)&&e.splice(t,1)}return"undefined"!=typeof document&&document.addEventListener("visibilitychange",function(){document.hidden?(_.forEach(function(n){return n.pause()}),nn=_.slice(0),_=[]):nn.forEach(function(n){return n.play()})}),tn.version="3.0.1",tn.speed=1,tn.running=_,tn.remove=function(n){for(var e=Z(n),t=_.length;t--;){var r=_[t],a=r.animations,u=r.children;rn(e,a);for(var o=u.length;o--;){var i=u[o],c=i.animations;rn(e,c),c.length||i.children.length||u.splice(o,1)}a.length||u.length||r.pause()}},tn.get=N,tn.set=R,tn.convertPx=B,tn.path=function(n,e){var t=i.str(n)?g(n)[0]:n,r=e||100;return function(n){return{property:n,el:t,svg:$(t),totalLength:q(t)*(r/100)}}},tn.setDashoffset=function(n){var e=q(n);return n.setAttribute("stroke-dasharray",e),e},tn.stagger=function(n,e){void 0===e&&(e={});var t=e.direction||"normal",r=e.easing?v(e.easing):null,a=e.grid,u=e.axis,o=e.from||0,c="first"===o,s="center"===o,f="last"===o,l=i.arr(n),d=l?parseFloat(n[0]):parseFloat(n),p=l?parseFloat(n[1]):0,h=C(l?n[1]:n)||0,g=e.start||0+(l?d:0),m=[],y=0;return function(n,e,i){if(c&&(o=0),s&&(o=(i-1)/2),f&&(o=i-1),!m.length){for(var v=0;v-1&&_.splice(u,1);for(var s=0;s Date: Wed, 24 Jul 2019 12:09:54 +0200 Subject: [PATCH 21/34] Fix loopBegin callback beeing called twice --- documentation/examples/anime-callbacks.html | 60 +++++++++++++-------- lib/anime.es.js | 22 +++++--- lib/anime.js | 22 +++++--- lib/anime.min.js | 2 +- src/index.js | 18 ++++--- 5 files changed, 79 insertions(+), 45 deletions(-) diff --git a/documentation/examples/anime-callbacks.html b/documentation/examples/anime-callbacks.html index 6e7c5b29..48ea5e5a 100644 --- a/documentation/examples/anime-callbacks.html +++ b/documentation/examples/anime-callbacks.html @@ -25,7 +25,8 @@ align-items: center; position: absolute; width: 100%; - height: 100%; + height: 100vh; + padding-bottom: 50vh; } .el { @@ -90,9 +91,9 @@ /* Player animation */ .timeline { - position: absolute; + position: fixed; bottom: 0; - height: 100px; + height: 50vh; padding-top: 4px; background-color: #000; } @@ -168,28 +169,29 @@ rotate: { value: 720, easing: 'easeInOutCirc', - duration: 1000, + duration: 500, delay: 500 }, opacity: { value: .5, easing: 'linear', - duration: 2000, - delay: 1500, + duration: 1000, + delay: 1000, endDelay: 0 }, delay: 1000, - endDelay: 1500, - duration: 2000, + endDelay: 500, + duration: 1000, easing: 'easeOutQuad', - direction: 'alternate', - loop: 3, + direction: 'reverse', + loop: 2, autoplay: false, update: function(a) { animationTimeLogEl.innerHTML = 'progress : ' + a.progress + '
currentTime : ' + a.currentTime; }, }); + var tl = anime.timeline({ targets: '.el.color-08', easing: 'easeInOutQuad', @@ -198,7 +200,6 @@ loop: 3, update: function(a) { timelineTimeLogEl.innerHTML = 'progress : ' + a.progress + '
currentTime : ' + a.currentTime; - // console.log(a.progress); } }) .add({ @@ -214,9 +215,6 @@ }, '-=500'); - console.log(tl); - - function animePlayer(instance, playerClass) { function createEl(type, className, parentEl) { @@ -243,14 +241,14 @@ 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, { + anime.set(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.set(anim.player.delayEl, {width: (anim.delay / anim.duration) * 100 + '%'}); + anime.set(anim.player.endDelayEl, {width: (anim.endDelay / anim.duration) * 100 + '%'}); } - anime.setValue(anim.player.animationEl, {color: colors[colorIndex]}); + anime.set(anim.player.animationEl, {color: colors[colorIndex]}); colorIndex++; if (!colors[colorIndex]) colorIndex = 0; anim.update(); @@ -269,12 +267,14 @@ easing: 'linear', update: function(a) { instance.seek(a.currentTime); + }, + complete: 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); }); @@ -328,9 +328,25 @@ } - logCallbacks(animation, document.querySelector('.log-animation'), ['begin', 'loopBegin', 'changeBegin', 'change', 'changeComplete', 'loopComplete', 'complete']); - - logCallbacks(tl, document.querySelector('.log-timeline'), ['begin', 'loopBegin', 'changeBegin', 'change', 'changeComplete', 'loopComplete', 'complete']); + logCallbacks(animation, document.querySelector('.log-animation'), [ + 'begin', + 'loopBegin', + 'changeBegin', + 'change', + 'changeComplete', + 'loopComplete', + 'complete' + ]); + + + logCallbacks(tl, document.querySelector('.log-timeline'), ['begin', + 'loopBegin', + 'changeBegin', + 'change', + 'changeComplete', + 'loopComplete', + 'complete' + ]); diff --git a/lib/anime.es.js b/lib/anime.es.js index 0dc96339..c18ef272 100644 --- a/lib/anime.es.js +++ b/lib/anime.es.js @@ -559,8 +559,8 @@ function setDashoffset(el) { function getParentSvgEl(el) { var parentEl = el.parentNode; while (is.svg(parentEl)) { - parentEl = parentEl.parentNode; if (!is.svg(parentEl.parentNode)) { break; } + parentEl = parentEl.parentNode; } return parentEl; } @@ -1024,6 +1024,9 @@ function anime(params) { if (!instance.began && instance.currentTime > 0) { instance.began = true; setCallback('begin'); + } + if (!instance.loopBegan && instance.currentTime > 0) { + instance.loopBegan = true; setCallback('loopBegin'); } if (insTime <= insDelay && instance.currentTime !== 0) { @@ -1052,12 +1055,7 @@ function anime(params) { if (engineTime >= insDuration) { lastTime = 0; countIteration(); - if (instance.remaining) { - startTime = now; - setCallback('loopComplete'); - setCallback('loopBegin'); - if (instance.direction === 'alternate') { toggleInstanceDirection(); } - } else { + if (!instance.remaining) { instance.paused = true; if (!instance.completed) { instance.completed = true; @@ -1068,6 +1066,13 @@ function anime(params) { promise = makePromise(instance); } } + } else { + startTime = now; + setCallback('loopComplete'); + instance.loopBegan = false; + if (instance.direction === 'alternate') { + toggleInstanceDirection(); + } } } } @@ -1079,6 +1084,7 @@ function anime(params) { instance.progress = 0; instance.paused = true; instance.began = false; + instance.loopBegan = false; instance.changeBegan = false; instance.completed = false; instance.changeCompleted = false; @@ -1089,7 +1095,7 @@ function anime(params) { childrenLength = children.length; for (var i = childrenLength; i--;) { instance.children[i].reset(); } if (instance.reversed && instance.loop !== true || (direction === 'alternate' && instance.loop === 1)) { instance.remaining++; } - setAnimationsProgress(0); + setAnimationsProgress(instance.reversed ? instance.duration : 0); }; // Set Value helper diff --git a/lib/anime.js b/lib/anime.js index 1925db27..0d868a31 100644 --- a/lib/anime.js +++ b/lib/anime.js @@ -561,8 +561,8 @@ function setDashoffset(el) { function getParentSvgEl(el) { var parentEl = el.parentNode; while (is.svg(parentEl)) { - parentEl = parentEl.parentNode; if (!is.svg(parentEl.parentNode)) { break; } + parentEl = parentEl.parentNode; } return parentEl; } @@ -1026,6 +1026,9 @@ function anime(params) { if (!instance.began && instance.currentTime > 0) { instance.began = true; setCallback('begin'); + } + if (!instance.loopBegan && instance.currentTime > 0) { + instance.loopBegan = true; setCallback('loopBegin'); } if (insTime <= insDelay && instance.currentTime !== 0) { @@ -1054,12 +1057,7 @@ function anime(params) { if (engineTime >= insDuration) { lastTime = 0; countIteration(); - if (instance.remaining) { - startTime = now; - setCallback('loopComplete'); - setCallback('loopBegin'); - if (instance.direction === 'alternate') { toggleInstanceDirection(); } - } else { + if (!instance.remaining) { instance.paused = true; if (!instance.completed) { instance.completed = true; @@ -1070,6 +1068,13 @@ function anime(params) { promise = makePromise(instance); } } + } else { + startTime = now; + setCallback('loopComplete'); + instance.loopBegan = false; + if (instance.direction === 'alternate') { + toggleInstanceDirection(); + } } } } @@ -1081,6 +1086,7 @@ function anime(params) { instance.progress = 0; instance.paused = true; instance.began = false; + instance.loopBegan = false; instance.changeBegan = false; instance.completed = false; instance.changeCompleted = false; @@ -1091,7 +1097,7 @@ function anime(params) { childrenLength = children.length; for (var i = childrenLength; i--;) { instance.children[i].reset(); } if (instance.reversed && instance.loop !== true || (direction === 'alternate' && instance.loop === 1)) { instance.remaining++; } - setAnimationsProgress(0); + setAnimationsProgress(instance.reversed ? instance.duration : 0); }; // Set Value helper diff --git a/lib/anime.min.js b/lib/anime.min.js index fc84a898..cc4620db 100644 --- a/lib/anime.min.js +++ b/lib/anime.min.js @@ -5,4 +5,4 @@ * animejs.com */ -!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):n.anime=e()}(this,function(){"use strict";var n={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0},e={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(n,e,t){return Math.min(Math.max(n,e),t)}function u(n,e){return n.indexOf(e)>-1}function o(n,e){return n.apply(null,e)}var i={arr:function(n){return Array.isArray(n)},obj:function(n){return u(Object.prototype.toString.call(n),"Object")},pth:function(n){return i.obj(n)&&n.hasOwnProperty("totalLength")},svg:function(n){return n instanceof SVGElement},inp:function(n){return n instanceof HTMLInputElement},dom:function(n){return n.nodeType||i.svg(n)},str:function(n){return"string"==typeof n},fnc:function(n){return"function"==typeof n},und:function(n){return void 0===n},hex:function(n){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(n)},rgb:function(n){return/^rgb/.test(n)},hsl:function(n){return/^hsl/.test(n)},col:function(n){return i.hex(n)||i.rgb(n)||i.hsl(n)},key:function(t){return!n.hasOwnProperty(t)&&!e.hasOwnProperty(t)&&"targets"!==t&&"keyframes"!==t}};function c(n){var e=/\(([^)]+)\)/.exec(n);return e?e[1].split(",").map(function(n){return parseFloat(n)}):[]}function s(n,e){var t=c(n),u=a(i.und(t[0])?1:t[0],.1,100),o=a(i.und(t[1])?100:t[1],.1,100),s=a(i.und(t[2])?10:t[2],.1,100),f=a(i.und(t[3])?0:t[3],.1,100),l=Math.sqrt(o/u),d=s/(2*Math.sqrt(o*u)),p=d<1?l*Math.sqrt(1-d*d):0,h=1,v=d<1?(d*l-f)/p:-f+l;function g(n){var t=e?e*n/1e3:n;return t=d<1?Math.exp(-t*d*l)*(h*Math.cos(p*t)+v*Math.sin(p*t)):(h+v*t)*Math.exp(-t*l),0===n||1===n?n:1-t}return e?g:function(){var e=r.springs[n];if(e)return e;for(var t=0,a=0;;)if(1===g(t+=1/6)){if(++a>=16)break}else a=0;var u=t*(1/6)*1e3;return r.springs[n]=u,u}}function f(n){return void 0===n&&(n=10),function(e){return Math.round(e*n)*(1/n)}}var l,d,p=function(){var n=11,e=1/(n-1);function t(n,e){return 1-3*e+3*n}function r(n,e){return 3*e-6*n}function a(n){return 3*n}function u(n,e,u){return((t(e,u)*n+r(e,u))*n+a(e))*n}function o(n,e,u){return 3*t(e,u)*n*n+2*r(e,u)*n+a(e)}return function(t,r,a,i){if(0<=t&&t<=1&&0<=a&&a<=1){var c=new Float32Array(n);if(t!==r||a!==i)for(var s=0;s=.001?function(n,e,t,r){for(var a=0;a<4;++a){var i=o(e,t,r);if(0===i)return e;e-=(u(e,t,r)-n)/i}return e}(r,l,t,a):0===d?l:function(n,e,t,r,a){for(var o,i,c=0;(o=u(i=e+(t-e)/2,r,a)-n)>0?t=i:e=i,Math.abs(o)>1e-7&&++c<10;);return i}(r,i,i+e,t,a)}}}(),h=(l={linear:function(){return function(n){return n}}},d={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var e,t=4;n<((e=Math.pow(2,--t))-1)/11;);return 1/Math.pow(4,3-t)-7.5625*Math.pow((3*e-2)/22-n,2)}},Elastic:function(n,e){void 0===n&&(n=1),void 0===e&&(e=.5);var t=a(n,1,10),r=a(e,.1,2);return function(n){return 0===n||1===n?n:-t*Math.pow(2,10*(n-1))*Math.sin((n-1-r/(2*Math.PI)*Math.asin(1/t))*(2*Math.PI)/r)}}},["Quad","Cubic","Quart","Quint","Expo"].forEach(function(n,e){d[n]=function(){return function(n){return Math.pow(n,e+2)}}}),Object.keys(d).forEach(function(n){var e=d[n];l["easeIn"+n]=e,l["easeOut"+n]=function(n,t){return function(r){return 1-e(n,t)(1-r)}},l["easeInOut"+n]=function(n,t){return function(r){return r<.5?e(n,t)(2*r)/2:1-e(n,t)(-2*r+2)/2}}}),l);function v(n,e){if(i.fnc(n))return n;var t=n.split("(")[0],r=h[t],a=c(n);switch(t){case"spring":return s(n,e);case"cubicBezier":return o(p,a);case"steps":return o(f,a);default:return o(r,a)}}function g(n){try{return document.querySelectorAll(n)}catch(n){return}}function m(n,e){for(var t=n.length,r=arguments.length>=2?arguments[1]:void 0,a=[],u=0;u1&&(t-=1),t<1/6?n+6*(e-n)*t:t<.5?e:t<2/3?n+(e-n)*(2/3-t)*6:n}if(0==o)e=t=r=i;else{var f=i<.5?i*(1+o):i+o-i*o,l=2*i-f;e=s(l,f,u+1/3),t=s(l,f,u),r=s(l,f,u-1/3)}return"rgba("+255*e+","+255*t+","+255*r+","+c+")"}(n):void 0;var e,t,r,a}function C(n){var e=/([\+\-]?[0-9#\.]+)(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(n);if(e)return e[2]}function P(n,e){return i.fnc(n)?n(e.target,e.id,e.total):n}function I(n,e){return n.getAttribute(e)}function B(n,e,t){if(M([t,"deg","rad","turn"],C(e)))return e;var a=r.CSS[e+t];if(!i.und(a))return a;var u=document.createElement(n.tagName),o=n.parentNode&&n.parentNode!==document?n.parentNode:document.body;o.appendChild(u),u.style.position="absolute",u.style.width=100+t;var c=100/u.offsetWidth;o.removeChild(u);var s=c*parseFloat(e);return r.CSS[e+t]=s,s}function D(n,e,t){if(e in n.style){var r=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),a=n.style[e]||getComputedStyle(n).getPropertyValue(r)||"0";return t?B(n,a,t):a}}function T(n,e){return i.dom(n)&&!i.inp(n)&&(I(n,e)||i.svg(n)&&n[e])?"attribute":i.dom(n)&&M(t,e)?"transform":i.dom(n)&&"transform"!==e&&D(n,e)?"css":null!=n[e]?"object":void 0}function E(n){if(i.dom(n)){for(var e,t=n.style.transform||"",r=/(\w+)\(([^)]*)\)/g,a=new Map;e=r.exec(t);)a.set(e[1],e[2]);return a}}function F(n,e,t,r){var a,o=u(e,"scale")?1:0+(u(a=e,"translate")||"perspective"===a?"px":u(a,"rotate")||u(a,"skew")?"deg":void 0),i=E(n).get(e)||o;return t&&(t.transforms.list.set(e,i),t.transforms.last=e),r?B(n,i,r):i}function N(n,e,t,r){switch(T(n,e)){case"transform":return F(n,e,r,t);case"css":return D(n,e,t);case"attribute":return I(n,e);default:return n[e]||0}}function A(n,e){var t=/^(\*=|\+=|-=)/.exec(n);if(!t)return n;var r=C(n)||0,a=parseFloat(e),u=parseFloat(n.replace(t[0],""));switch(t[0][0]){case"+":return a+u+r;case"-":return a-u+r;case"*":return a*u+r}}function L(n,e){if(i.col(n))return O(n);if(/\s/g.test(n))return n;var t=C(n),r=t?n.substr(0,n.length-t.length):n;return e?r+e:r}function j(n,e){return Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2))}function S(n){for(var e,t=n.points,r=0,a=0;a0&&(r+=j(e,u)),e=u}return r}function q(n){if(n.getTotalLength)return n.getTotalLength();switch(n.tagName.toLowerCase()){case"circle":return u=n,2*Math.PI*I(u,"r");case"rect":return 2*I(a=n,"width")+2*I(a,"height");case"line":return j({x:I(r=n,"x1"),y:I(r,"y1")},{x:I(r,"x2"),y:I(r,"y2")});case"polyline":return S(n);case"polygon":return t=(e=n).points,S(e)+j(t.getItem(t.numberOfItems-1),t.getItem(0))}var e,t,r,a,u}function $(n,e){var t=e||{},r=t.el||function(n){for(var e=n.parentNode;i.svg(e)&&(e=e.parentNode,i.svg(e.parentNode)););return e}(n),a=r.getBoundingClientRect(),u=I(r,"viewBox"),o=a.width,c=a.height,s=t.viewBox||(u?u.split(" "):[0,0,o,c]);return{el:r,viewBox:s,x:s[0]/1,y:s[1]/1,w:o/s[2],h:c/s[3]}}function X(n,e){function t(t){void 0===t&&(t=0);var r=e+t>=1?e+t:0;return n.el.getPointAtLength(r)}var r=$(n.el,n.svg),a=t(),u=t(-1),o=t(1);switch(n.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-u.y,o.x-u.x)/Math.PI}}function Y(n,e){var t=/-?\d*\.?\d+/g,r=L(i.pth(n)?n.totalLength:n,e)+"";return{original:r,numbers:r.match(t)?r.match(t).map(Number):[0],strings:i.str(n)||e?r.split(t):[]}}function Z(n){return m(n?y(i.arr(n)?n.map(b):b(n)):[],function(n,e,t){return t.indexOf(n)===e})}function Q(n){var e=Z(n);return e.map(function(n,t){return{target:n,id:t,total:e.length,transforms:{list:E(n)}}})}function V(n,e){var t=x(e);if(/^spring/.test(t.easing)&&(t.duration=s(t.easing)),i.arr(n)){var r=n.length;2===r&&!i.obj(n[0])?n={value:n}:i.fnc(e.duration)||(t.duration=e.duration/r)}var a=i.arr(n)?n:[n];return a.map(function(n,t){var r=i.obj(n)&&!i.pth(n)?n:{value:n};return i.und(r.delay)&&(r.delay=t?0:e.delay),i.und(r.endDelay)&&(r.endDelay=t===a.length-1?e.endDelay:0),r}).map(function(n){return k(n,t)})}function z(n,e){var t=[],r=e.keyframes;for(var a in r&&(e=k(function(n){for(var e=m(y(n.map(function(n){return Object.keys(n)})),function(n){return i.key(n)}).reduce(function(n,e){return n.indexOf(e)<0&&n.push(e),n},[]),t={},r=function(r){var a=e[r];t[a]=n.map(function(n){var e={};for(var t in n)i.key(t)?t==a&&(e.value=n[t]):e[t]=n[t];return e})},a=0;a-1&&(_.splice(u,1),t=_.length)}else a.tick(e);r++}n()}else U=cancelAnimationFrame(U)}return n}();function tn(t){void 0===t&&(t={});var r,u=0,o=0,i=0,c=0,s=null;function f(n){var e=window.Promise&&new Promise(function(n){return s=n});return n.finished=e,e}var l,d,p,h,v,g,y,b,M=(d=w(n,l=t),p=w(e,l),h=z(p,l),v=Q(l.targets),g=W(v,h),y=J(g,p),b=K,K++,k(d,{id:b,children:[],animatables:v,animations:g,duration:y.duration,delay:y.delay,endDelay:y.endDelay}));f(M);function x(){var n=M.direction;"alternate"!==n&&(M.direction="normal"!==n?"normal":"reverse"),M.reversed=!M.reversed,r.forEach(function(n){return n.reversed=M.reversed})}function O(n){return M.reversed?M.duration-n:n}function C(){u=0,o=O(M.currentTime)*(1/tn.speed)}function P(n,e){e&&e.seek(n-e.timelineOffset)}function I(n){for(var e=0,t=M.animations,r=t.length;e2||(b=Math.round(b*p)/p)),h.push(b)}var k=d.length;if(k){g=d[0];for(var O=0;O0&&(M.began=!0,B("begin"),B("loopBegin")),d<=t&&0!==M.currentTime&&I(0),(d>=l&&M.currentTime!==e||!e)&&I(e),d>t&&d=e&&(o=0,M.remaining&&!0!==M.remaining&&M.remaining--,M.remaining?(u=i,B("loopComplete"),B("loopBegin"),"alternate"===M.direction&&x()):(M.paused=!0,M.completed||(M.completed=!0,B("loopComplete"),B("complete"),!M.passThrough&&"Promise"in window&&(s(),f(M)))))}return M.reset=function(){var n=M.direction;M.passThrough=!1,M.currentTime=0,M.progress=0,M.paused=!0,M.began=!1,M.changeBegan=!1,M.completed=!1,M.changeCompleted=!1,M.reversePlayback=!1,M.reversed="reverse"===n,M.remaining=M.loop,r=M.children;for(var e=c=r.length;e--;)M.children[e].reset();(M.reversed&&!0!==M.loop||"alternate"===n&&1===M.loop)&&M.remaining++,I(0)},M.set=function(n,e){return R(n,e),M},M.tick=function(n){i=n,u||(u=i),D((i+(o-u))*tn.speed)},M.seek=function(n){D(O(n))},M.pause=function(){M.paused=!0,C()},M.play=function(){M.paused&&(M.completed&&M.reset(),M.paused=!1,_.push(M),C(),U||en())},M.reverse=function(){x(),C()},M.restart=function(){M.reset(),M.play()},M.reset(),M.autoplay&&M.play(),M}function rn(n,e){for(var t=e.length;t--;)M(n,e[t].animatable.target)&&e.splice(t,1)}return"undefined"!=typeof document&&document.addEventListener("visibilitychange",function(){document.hidden?(_.forEach(function(n){return n.pause()}),nn=_.slice(0),_=[]):nn.forEach(function(n){return n.play()})}),tn.version="3.0.1",tn.speed=1,tn.running=_,tn.remove=function(n){for(var e=Z(n),t=_.length;t--;){var r=_[t],a=r.animations,u=r.children;rn(e,a);for(var o=u.length;o--;){var i=u[o],c=i.animations;rn(e,c),c.length||i.children.length||u.splice(o,1)}a.length||u.length||r.pause()}},tn.get=N,tn.set=R,tn.convertPx=B,tn.path=function(n,e){var t=i.str(n)?g(n)[0]:n,r=e||100;return function(n){return{property:n,el:t,svg:$(t),totalLength:q(t)*(r/100)}}},tn.setDashoffset=function(n){var e=q(n);return n.setAttribute("stroke-dasharray",e),e},tn.stagger=function(n,e){void 0===e&&(e={});var t=e.direction||"normal",r=e.easing?v(e.easing):null,a=e.grid,u=e.axis,o=e.from||0,c="first"===o,s="center"===o,f="last"===o,l=i.arr(n),d=l?parseFloat(n[0]):parseFloat(n),p=l?parseFloat(n[1]):0,h=C(l?n[1]:n)||0,g=e.start||0+(l?d:0),m=[],y=0;return function(n,e,i){if(c&&(o=0),s&&(o=(i-1)/2),f&&(o=i-1),!m.length){for(var v=0;v-1&&_.splice(u,1);for(var s=0;s-1}function u(n,e){return n.apply(null,e)}var i={arr:function(n){return Array.isArray(n)},obj:function(n){return o(Object.prototype.toString.call(n),"Object")},pth:function(n){return i.obj(n)&&n.hasOwnProperty("totalLength")},svg:function(n){return n instanceof SVGElement},inp:function(n){return n instanceof HTMLInputElement},dom:function(n){return n.nodeType||i.svg(n)},str:function(n){return"string"==typeof n},fnc:function(n){return"function"==typeof n},und:function(n){return void 0===n},hex:function(n){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(n)},rgb:function(n){return/^rgb/.test(n)},hsl:function(n){return/^hsl/.test(n)},col:function(n){return i.hex(n)||i.rgb(n)||i.hsl(n)},key:function(r){return!n.hasOwnProperty(r)&&!e.hasOwnProperty(r)&&"targets"!==r&&"keyframes"!==r}};function c(n){var e=/\(([^)]+)\)/.exec(n);return e?e[1].split(",").map(function(n){return parseFloat(n)}):[]}function s(n,e){var r=c(n),o=a(i.und(r[0])?1:r[0],.1,100),u=a(i.und(r[1])?100:r[1],.1,100),s=a(i.und(r[2])?10:r[2],.1,100),f=a(i.und(r[3])?0:r[3],.1,100),l=Math.sqrt(u/o),d=s/(2*Math.sqrt(u*o)),p=d<1?l*Math.sqrt(1-d*d):0,h=1,v=d<1?(d*l-f)/p:-f+l;function g(n){var r=e?e*n/1e3:n;return r=d<1?Math.exp(-r*d*l)*(h*Math.cos(p*r)+v*Math.sin(p*r)):(h+v*r)*Math.exp(-r*l),0===n||1===n?n:1-r}return e?g:function(){var e=t.springs[n];if(e)return e;for(var r=0,a=0;;)if(1===g(r+=1/6)){if(++a>=16)break}else a=0;var o=r*(1/6)*1e3;return t.springs[n]=o,o}}function f(n){return void 0===n&&(n=10),function(e){return Math.round(e*n)*(1/n)}}var l,d,p=function(){var n=11,e=1/(n-1);function r(n,e){return 1-3*e+3*n}function t(n,e){return 3*e-6*n}function a(n){return 3*n}function o(n,e,o){return((r(e,o)*n+t(e,o))*n+a(e))*n}function u(n,e,o){return 3*r(e,o)*n*n+2*t(e,o)*n+a(e)}return function(r,t,a,i){if(0<=r&&r<=1&&0<=a&&a<=1){var c=new Float32Array(n);if(r!==t||a!==i)for(var s=0;s=.001?function(n,e,r,t){for(var a=0;a<4;++a){var i=u(e,r,t);if(0===i)return e;e-=(o(e,r,t)-n)/i}return e}(t,l,r,a):0===d?l:function(n,e,r,t,a){for(var u,i,c=0;(u=o(i=e+(r-e)/2,t,a)-n)>0?r=i:e=i,Math.abs(u)>1e-7&&++c<10;);return i}(t,i,i+e,r,a)}}}(),h=(l={linear:function(){return function(n){return n}}},d={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var e,r=4;n<((e=Math.pow(2,--r))-1)/11;);return 1/Math.pow(4,3-r)-7.5625*Math.pow((3*e-2)/22-n,2)}},Elastic:function(n,e){void 0===n&&(n=1),void 0===e&&(e=.5);var r=a(n,1,10),t=a(e,.1,2);return function(n){return 0===n||1===n?n:-r*Math.pow(2,10*(n-1))*Math.sin((n-1-t/(2*Math.PI)*Math.asin(1/r))*(2*Math.PI)/t)}}},["Quad","Cubic","Quart","Quint","Expo"].forEach(function(n,e){d[n]=function(){return function(n){return Math.pow(n,e+2)}}}),Object.keys(d).forEach(function(n){var e=d[n];l["easeIn"+n]=e,l["easeOut"+n]=function(n,r){return function(t){return 1-e(n,r)(1-t)}},l["easeInOut"+n]=function(n,r){return function(t){return t<.5?e(n,r)(2*t)/2:1-e(n,r)(-2*t+2)/2}}}),l);function v(n,e){if(i.fnc(n))return n;var r=n.split("(")[0],t=h[r],a=c(n);switch(r){case"spring":return s(n,e);case"cubicBezier":return u(p,a);case"steps":return u(f,a);default:return u(t,a)}}function g(n){try{return document.querySelectorAll(n)}catch(n){return}}function m(n,e){for(var r=n.length,t=arguments.length>=2?arguments[1]:void 0,a=[],o=0;o1&&(r-=1),r<1/6?n+6*(e-n)*r:r<.5?e:r<2/3?n+(e-n)*(2/3-r)*6:n}if(0==u)e=r=t=i;else{var f=i<.5?i*(1+u):i+u-i*u,l=2*i-f;e=s(l,f,o+1/3),r=s(l,f,o),t=s(l,f,o-1/3)}return"rgba("+255*e+","+255*r+","+255*t+","+c+")"}(n):void 0;var e,r,t,a}function C(n){var e=/([\+\-]?[0-9#\.]+)(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(n);if(e)return e[2]}function B(n,e){return i.fnc(n)?n(e.target,e.id,e.total):n}function P(n,e){return n.getAttribute(e)}function I(n,e,r){if(M([r,"deg","rad","turn"],C(e)))return e;var a=t.CSS[e+r];if(!i.und(a))return a;var o=document.createElement(n.tagName),u=n.parentNode&&n.parentNode!==document?n.parentNode:document.body;u.appendChild(o),o.style.position="absolute",o.style.width=100+r;var c=100/o.offsetWidth;u.removeChild(o);var s=c*parseFloat(e);return t.CSS[e+r]=s,s}function T(n,e,r){if(e in n.style){var t=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),a=n.style[e]||getComputedStyle(n).getPropertyValue(t)||"0";return r?I(n,a,r):a}}function D(n,e){return i.dom(n)&&!i.inp(n)&&(P(n,e)||i.svg(n)&&n[e])?"attribute":i.dom(n)&&M(r,e)?"transform":i.dom(n)&&"transform"!==e&&T(n,e)?"css":null!=n[e]?"object":void 0}function E(n){if(i.dom(n)){for(var e,r=n.style.transform||"",t=/(\w+)\(([^)]*)\)/g,a=new Map;e=t.exec(r);)a.set(e[1],e[2]);return a}}function F(n,e,r,t){var a,u=o(e,"scale")?1:0+(o(a=e,"translate")||"perspective"===a?"px":o(a,"rotate")||o(a,"skew")?"deg":void 0),i=E(n).get(e)||u;return r&&(r.transforms.list.set(e,i),r.transforms.last=e),t?I(n,i,t):i}function N(n,e,r,t){switch(D(n,e)){case"transform":return F(n,e,t,r);case"css":return T(n,e,r);case"attribute":return P(n,e);default:return n[e]||0}}function A(n,e){var r=/^(\*=|\+=|-=)/.exec(n);if(!r)return n;var t=C(n)||0,a=parseFloat(e),o=parseFloat(n.replace(r[0],""));switch(r[0][0]){case"+":return a+o+t;case"-":return a-o+t;case"*":return a*o+t}}function L(n,e){if(i.col(n))return O(n);if(/\s/g.test(n))return n;var r=C(n),t=r?n.substr(0,n.length-r.length):n;return e?t+e:t}function j(n,e){return Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2))}function S(n){for(var e,r=n.points,t=0,a=0;a0&&(t+=j(e,o)),e=o}return t}function q(n){if(n.getTotalLength)return n.getTotalLength();switch(n.tagName.toLowerCase()){case"circle":return o=n,2*Math.PI*P(o,"r");case"rect":return 2*P(a=n,"width")+2*P(a,"height");case"line":return j({x:P(t=n,"x1"),y:P(t,"y1")},{x:P(t,"x2"),y:P(t,"y2")});case"polyline":return S(n);case"polygon":return r=(e=n).points,S(e)+j(r.getItem(r.numberOfItems-1),r.getItem(0))}var e,r,t,a,o}function $(n,e){var r=e||{},t=r.el||function(n){for(var e=n.parentNode;i.svg(e)&&i.svg(e.parentNode);)e=e.parentNode;return e}(n),a=t.getBoundingClientRect(),o=P(t,"viewBox"),u=a.width,c=a.height,s=r.viewBox||(o?o.split(" "):[0,0,u,c]);return{el:t,viewBox:s,x:s[0]/1,y:s[1]/1,w:u/s[2],h:c/s[3]}}function X(n,e){function r(r){void 0===r&&(r=0);var t=e+r>=1?e+r:0;return n.el.getPointAtLength(t)}var t=$(n.el,n.svg),a=r(),o=r(-1),u=r(1);switch(n.property){case"x":return(a.x-t.x)*t.w;case"y":return(a.y-t.y)*t.h;case"angle":return 180*Math.atan2(u.y-o.y,u.x-o.x)/Math.PI}}function Y(n,e){var r=/-?\d*\.?\d+/g,t=L(i.pth(n)?n.totalLength:n,e)+"";return{original:t,numbers:t.match(r)?t.match(r).map(Number):[0],strings:i.str(n)||e?t.split(r):[]}}function Z(n){return m(n?y(i.arr(n)?n.map(b):b(n)):[],function(n,e,r){return r.indexOf(n)===e})}function Q(n){var e=Z(n);return e.map(function(n,r){return{target:n,id:r,total:e.length,transforms:{list:E(n)}}})}function V(n,e){var r=x(e);if(/^spring/.test(r.easing)&&(r.duration=s(r.easing)),i.arr(n)){var t=n.length;2===t&&!i.obj(n[0])?n={value:n}:i.fnc(e.duration)||(r.duration=e.duration/t)}var a=i.arr(n)?n:[n];return a.map(function(n,r){var t=i.obj(n)&&!i.pth(n)?n:{value:n};return i.und(t.delay)&&(t.delay=r?0:e.delay),i.und(t.endDelay)&&(t.endDelay=r===a.length-1?e.endDelay:0),t}).map(function(n){return k(n,r)})}function z(n,e){var r=[],t=e.keyframes;for(var a in t&&(e=k(function(n){for(var e=m(y(n.map(function(n){return Object.keys(n)})),function(n){return i.key(n)}).reduce(function(n,e){return n.indexOf(e)<0&&n.push(e),n},[]),r={},t=function(t){var a=e[t];r[a]=n.map(function(n){var e={};for(var r in n)i.key(r)?r==a&&(e.value=n[r]):e[r]=n[r];return e})},a=0;a-1&&(_.splice(o,1),r=_.length)}else a.tick(e);t++}n()}else U=cancelAnimationFrame(U)}return n}();function rn(r){void 0===r&&(r={});var t,o=0,u=0,i=0,c=0,s=null;function f(n){var e=window.Promise&&new Promise(function(n){return s=n});return n.finished=e,e}var l,d,p,h,v,g,y,b,M=(d=w(n,l=r),p=w(e,l),h=z(p,l),v=Q(l.targets),g=W(v,h),y=J(g,p),b=K,K++,k(d,{id:b,children:[],animatables:v,animations:g,duration:y.duration,delay:y.delay,endDelay:y.endDelay}));f(M);function x(){var n=M.direction;"alternate"!==n&&(M.direction="normal"!==n?"normal":"reverse"),M.reversed=!M.reversed,t.forEach(function(n){return n.reversed=M.reversed})}function O(n){return M.reversed?M.duration-n:n}function C(){o=0,u=O(M.currentTime)*(1/rn.speed)}function B(n,e){e&&e.seek(n-e.timelineOffset)}function P(n){for(var e=0,r=M.animations,t=r.length;e2||(b=Math.round(b*p)/p)),h.push(b)}var k=d.length;if(k){g=d[0];for(var O=0;O0&&(M.began=!0,I("begin")),!M.loopBegan&&M.currentTime>0&&(M.loopBegan=!0,I("loopBegin")),d<=r&&0!==M.currentTime&&P(0),(d>=l&&M.currentTime!==e||!e)&&P(e),d>r&&d=e&&(u=0,M.remaining&&!0!==M.remaining&&M.remaining--,M.remaining?(o=i,I("loopComplete"),M.loopBegan=!1,"alternate"===M.direction&&x()):(M.paused=!0,M.completed||(M.completed=!0,I("loopComplete"),I("complete"),!M.passThrough&&"Promise"in window&&(s(),f(M)))))}return M.reset=function(){var n=M.direction;M.passThrough=!1,M.currentTime=0,M.progress=0,M.paused=!0,M.began=!1,M.loopBegan=!1,M.changeBegan=!1,M.completed=!1,M.changeCompleted=!1,M.reversePlayback=!1,M.reversed="reverse"===n,M.remaining=M.loop,t=M.children;for(var e=c=t.length;e--;)M.children[e].reset();(M.reversed&&!0!==M.loop||"alternate"===n&&1===M.loop)&&M.remaining++,P(M.reversed?M.duration:0)},M.set=function(n,e){return R(n,e),M},M.tick=function(n){i=n,o||(o=i),T((i+(u-o))*rn.speed)},M.seek=function(n){T(O(n))},M.pause=function(){M.paused=!0,C()},M.play=function(){M.paused&&(M.completed&&M.reset(),M.paused=!1,_.push(M),C(),U||en())},M.reverse=function(){x(),C()},M.restart=function(){M.reset(),M.play()},M.reset(),M.autoplay&&M.play(),M}function tn(n,e){for(var r=e.length;r--;)M(n,e[r].animatable.target)&&e.splice(r,1)}return"undefined"!=typeof document&&document.addEventListener("visibilitychange",function(){document.hidden?(_.forEach(function(n){return n.pause()}),nn=_.slice(0),_=[]):nn.forEach(function(n){return n.play()})}),rn.version="3.0.1",rn.speed=1,rn.running=_,rn.remove=function(n){for(var e=Z(n),r=_.length;r--;){var t=_[r],a=t.animations,o=t.children;tn(e,a);for(var u=o.length;u--;){var i=o[u],c=i.animations;tn(e,c),c.length||i.children.length||o.splice(u,1)}a.length||o.length||t.pause()}},rn.get=N,rn.set=R,rn.convertPx=I,rn.path=function(n,e){var r=i.str(n)?g(n)[0]:n,t=e||100;return function(n){return{property:n,el:r,svg:$(r),totalLength:q(r)*(t/100)}}},rn.setDashoffset=function(n){var e=q(n);return n.setAttribute("stroke-dasharray",e),e},rn.stagger=function(n,e){void 0===e&&(e={});var r=e.direction||"normal",t=e.easing?v(e.easing):null,a=e.grid,o=e.axis,u=e.from||0,c="first"===u,s="center"===u,f="last"===u,l=i.arr(n),d=l?parseFloat(n[0]):parseFloat(n),p=l?parseFloat(n[1]):0,h=C(l?n[1]:n)||0,g=e.start||0+(l?d:0),m=[],y=0;return function(n,e,i){if(c&&(u=0),s&&(u=(i-1)/2),f&&(u=i-1),!m.length){for(var v=0;v-1&&_.splice(o,1);for(var s=0;s 0) { instance.began = true; setCallback('begin'); + } + if (!instance.loopBegan && instance.currentTime > 0) { + instance.loopBegan = true; setCallback('loopBegin'); } if (insTime <= insDelay && instance.currentTime !== 0) { @@ -1034,12 +1037,7 @@ function anime(params = {}) { if (engineTime >= insDuration) { lastTime = 0; countIteration(); - if (instance.remaining) { - startTime = now; - setCallback('loopComplete'); - setCallback('loopBegin'); - if (instance.direction === 'alternate') { toggleInstanceDirection(); } - } else { + if (!instance.remaining) { instance.paused = true; if (!instance.completed) { instance.completed = true; @@ -1050,6 +1048,13 @@ function anime(params = {}) { promise = makePromise(instance); } } + } else { + startTime = now; + setCallback('loopComplete'); + instance.loopBegan = false; + if (instance.direction === 'alternate') { + toggleInstanceDirection(); + } } } } @@ -1061,6 +1066,7 @@ function anime(params = {}) { instance.progress = 0; instance.paused = true; instance.began = false; + instance.loopBegan = false; instance.changeBegan = false; instance.completed = false; instance.changeCompleted = false; From 1730d5de1c9f8d862cede2e2570392ce96a7af11 Mon Sep 17 00:00:00 2001 From: Julian Garnier Date: Thu, 25 Jul 2019 10:43:28 +0200 Subject: [PATCH 22/34] Better number parsing --- .../examples/anime-complex-properties.html | 57 ++++++++++++------- lib/anime.es.js | 8 ++- lib/anime.js | 8 ++- lib/anime.min.js | 2 +- src/index.js | 8 ++- 5 files changed, 51 insertions(+), 32 deletions(-) diff --git a/documentation/examples/anime-complex-properties.html b/documentation/examples/anime-complex-properties.html index 3467b289..23484bfc 100644 --- a/documentation/examples/anime-complex-properties.html +++ b/documentation/examples/anime-complex-properties.html @@ -45,6 +45,11 @@ background-image: radial-gradient(50% 100%, #FFF7A0 50%, #FF7A6D 100%); background-size: auto 100px; } + .exponent-values { + width: 300px; + background-color: transparent; + text-align: center; + } @@ -67,6 +72,7 @@
+ diff --git a/lib/anime.es.js b/lib/anime.es.js index c18ef272..6536c994 100644 --- a/lib/anime.es.js +++ b/lib/anime.es.js @@ -393,8 +393,8 @@ function colorToRgb(val) { // Units function getUnit(val) { - var 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]; } + var split = /[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(val); + if (split) { return split[1]; } } function getTransformUnit(propName) { @@ -617,7 +617,9 @@ function getPathProgress(path, progress) { // Decompose value function decomposeValue(val, unit) { - var rgx = /-?\d*\.?\d+/g; + // const rgx = /-?\d*\.?\d+/g; // handles basic numbers + // const rgx = /[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g; // handles exponents notation + var rgx = /[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g; // handles exponents notation var value = validateValue((is.pth(val) ? val.totalLength : val), unit) + ''; return { original: value, diff --git a/lib/anime.js b/lib/anime.js index 0d868a31..678266db 100644 --- a/lib/anime.js +++ b/lib/anime.js @@ -395,8 +395,8 @@ function colorToRgb(val) { // Units function getUnit(val) { - var 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]; } + var split = /[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(val); + if (split) { return split[1]; } } function getTransformUnit(propName) { @@ -619,7 +619,9 @@ function getPathProgress(path, progress) { // Decompose value function decomposeValue(val, unit) { - var rgx = /-?\d*\.?\d+/g; + // const rgx = /-?\d*\.?\d+/g; // handles basic numbers + // const rgx = /[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g; // handles exponents notation + var rgx = /[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g; // handles exponents notation var value = validateValue((is.pth(val) ? val.totalLength : val), unit) + ''; return { original: value, diff --git a/lib/anime.min.js b/lib/anime.min.js index cc4620db..469d1097 100644 --- a/lib/anime.min.js +++ b/lib/anime.min.js @@ -5,4 +5,4 @@ * animejs.com */ -!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):n.anime=e()}(this,function(){"use strict";var n={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0},e={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},r=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective"],t={CSS:{},springs:{}};function a(n,e,r){return Math.min(Math.max(n,e),r)}function o(n,e){return n.indexOf(e)>-1}function u(n,e){return n.apply(null,e)}var i={arr:function(n){return Array.isArray(n)},obj:function(n){return o(Object.prototype.toString.call(n),"Object")},pth:function(n){return i.obj(n)&&n.hasOwnProperty("totalLength")},svg:function(n){return n instanceof SVGElement},inp:function(n){return n instanceof HTMLInputElement},dom:function(n){return n.nodeType||i.svg(n)},str:function(n){return"string"==typeof n},fnc:function(n){return"function"==typeof n},und:function(n){return void 0===n},hex:function(n){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(n)},rgb:function(n){return/^rgb/.test(n)},hsl:function(n){return/^hsl/.test(n)},col:function(n){return i.hex(n)||i.rgb(n)||i.hsl(n)},key:function(r){return!n.hasOwnProperty(r)&&!e.hasOwnProperty(r)&&"targets"!==r&&"keyframes"!==r}};function c(n){var e=/\(([^)]+)\)/.exec(n);return e?e[1].split(",").map(function(n){return parseFloat(n)}):[]}function s(n,e){var r=c(n),o=a(i.und(r[0])?1:r[0],.1,100),u=a(i.und(r[1])?100:r[1],.1,100),s=a(i.und(r[2])?10:r[2],.1,100),f=a(i.und(r[3])?0:r[3],.1,100),l=Math.sqrt(u/o),d=s/(2*Math.sqrt(u*o)),p=d<1?l*Math.sqrt(1-d*d):0,h=1,v=d<1?(d*l-f)/p:-f+l;function g(n){var r=e?e*n/1e3:n;return r=d<1?Math.exp(-r*d*l)*(h*Math.cos(p*r)+v*Math.sin(p*r)):(h+v*r)*Math.exp(-r*l),0===n||1===n?n:1-r}return e?g:function(){var e=t.springs[n];if(e)return e;for(var r=0,a=0;;)if(1===g(r+=1/6)){if(++a>=16)break}else a=0;var o=r*(1/6)*1e3;return t.springs[n]=o,o}}function f(n){return void 0===n&&(n=10),function(e){return Math.round(e*n)*(1/n)}}var l,d,p=function(){var n=11,e=1/(n-1);function r(n,e){return 1-3*e+3*n}function t(n,e){return 3*e-6*n}function a(n){return 3*n}function o(n,e,o){return((r(e,o)*n+t(e,o))*n+a(e))*n}function u(n,e,o){return 3*r(e,o)*n*n+2*t(e,o)*n+a(e)}return function(r,t,a,i){if(0<=r&&r<=1&&0<=a&&a<=1){var c=new Float32Array(n);if(r!==t||a!==i)for(var s=0;s=.001?function(n,e,r,t){for(var a=0;a<4;++a){var i=u(e,r,t);if(0===i)return e;e-=(o(e,r,t)-n)/i}return e}(t,l,r,a):0===d?l:function(n,e,r,t,a){for(var u,i,c=0;(u=o(i=e+(r-e)/2,t,a)-n)>0?r=i:e=i,Math.abs(u)>1e-7&&++c<10;);return i}(t,i,i+e,r,a)}}}(),h=(l={linear:function(){return function(n){return n}}},d={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var e,r=4;n<((e=Math.pow(2,--r))-1)/11;);return 1/Math.pow(4,3-r)-7.5625*Math.pow((3*e-2)/22-n,2)}},Elastic:function(n,e){void 0===n&&(n=1),void 0===e&&(e=.5);var r=a(n,1,10),t=a(e,.1,2);return function(n){return 0===n||1===n?n:-r*Math.pow(2,10*(n-1))*Math.sin((n-1-t/(2*Math.PI)*Math.asin(1/r))*(2*Math.PI)/t)}}},["Quad","Cubic","Quart","Quint","Expo"].forEach(function(n,e){d[n]=function(){return function(n){return Math.pow(n,e+2)}}}),Object.keys(d).forEach(function(n){var e=d[n];l["easeIn"+n]=e,l["easeOut"+n]=function(n,r){return function(t){return 1-e(n,r)(1-t)}},l["easeInOut"+n]=function(n,r){return function(t){return t<.5?e(n,r)(2*t)/2:1-e(n,r)(-2*t+2)/2}}}),l);function v(n,e){if(i.fnc(n))return n;var r=n.split("(")[0],t=h[r],a=c(n);switch(r){case"spring":return s(n,e);case"cubicBezier":return u(p,a);case"steps":return u(f,a);default:return u(t,a)}}function g(n){try{return document.querySelectorAll(n)}catch(n){return}}function m(n,e){for(var r=n.length,t=arguments.length>=2?arguments[1]:void 0,a=[],o=0;o1&&(r-=1),r<1/6?n+6*(e-n)*r:r<.5?e:r<2/3?n+(e-n)*(2/3-r)*6:n}if(0==u)e=r=t=i;else{var f=i<.5?i*(1+u):i+u-i*u,l=2*i-f;e=s(l,f,o+1/3),r=s(l,f,o),t=s(l,f,o-1/3)}return"rgba("+255*e+","+255*r+","+255*t+","+c+")"}(n):void 0;var e,r,t,a}function C(n){var e=/([\+\-]?[0-9#\.]+)(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(n);if(e)return e[2]}function B(n,e){return i.fnc(n)?n(e.target,e.id,e.total):n}function P(n,e){return n.getAttribute(e)}function I(n,e,r){if(M([r,"deg","rad","turn"],C(e)))return e;var a=t.CSS[e+r];if(!i.und(a))return a;var o=document.createElement(n.tagName),u=n.parentNode&&n.parentNode!==document?n.parentNode:document.body;u.appendChild(o),o.style.position="absolute",o.style.width=100+r;var c=100/o.offsetWidth;u.removeChild(o);var s=c*parseFloat(e);return t.CSS[e+r]=s,s}function T(n,e,r){if(e in n.style){var t=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),a=n.style[e]||getComputedStyle(n).getPropertyValue(t)||"0";return r?I(n,a,r):a}}function D(n,e){return i.dom(n)&&!i.inp(n)&&(P(n,e)||i.svg(n)&&n[e])?"attribute":i.dom(n)&&M(r,e)?"transform":i.dom(n)&&"transform"!==e&&T(n,e)?"css":null!=n[e]?"object":void 0}function E(n){if(i.dom(n)){for(var e,r=n.style.transform||"",t=/(\w+)\(([^)]*)\)/g,a=new Map;e=t.exec(r);)a.set(e[1],e[2]);return a}}function F(n,e,r,t){var a,u=o(e,"scale")?1:0+(o(a=e,"translate")||"perspective"===a?"px":o(a,"rotate")||o(a,"skew")?"deg":void 0),i=E(n).get(e)||u;return r&&(r.transforms.list.set(e,i),r.transforms.last=e),t?I(n,i,t):i}function N(n,e,r,t){switch(D(n,e)){case"transform":return F(n,e,t,r);case"css":return T(n,e,r);case"attribute":return P(n,e);default:return n[e]||0}}function A(n,e){var r=/^(\*=|\+=|-=)/.exec(n);if(!r)return n;var t=C(n)||0,a=parseFloat(e),o=parseFloat(n.replace(r[0],""));switch(r[0][0]){case"+":return a+o+t;case"-":return a-o+t;case"*":return a*o+t}}function L(n,e){if(i.col(n))return O(n);if(/\s/g.test(n))return n;var r=C(n),t=r?n.substr(0,n.length-r.length):n;return e?t+e:t}function j(n,e){return Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2))}function S(n){for(var e,r=n.points,t=0,a=0;a0&&(t+=j(e,o)),e=o}return t}function q(n){if(n.getTotalLength)return n.getTotalLength();switch(n.tagName.toLowerCase()){case"circle":return o=n,2*Math.PI*P(o,"r");case"rect":return 2*P(a=n,"width")+2*P(a,"height");case"line":return j({x:P(t=n,"x1"),y:P(t,"y1")},{x:P(t,"x2"),y:P(t,"y2")});case"polyline":return S(n);case"polygon":return r=(e=n).points,S(e)+j(r.getItem(r.numberOfItems-1),r.getItem(0))}var e,r,t,a,o}function $(n,e){var r=e||{},t=r.el||function(n){for(var e=n.parentNode;i.svg(e)&&i.svg(e.parentNode);)e=e.parentNode;return e}(n),a=t.getBoundingClientRect(),o=P(t,"viewBox"),u=a.width,c=a.height,s=r.viewBox||(o?o.split(" "):[0,0,u,c]);return{el:t,viewBox:s,x:s[0]/1,y:s[1]/1,w:u/s[2],h:c/s[3]}}function X(n,e){function r(r){void 0===r&&(r=0);var t=e+r>=1?e+r:0;return n.el.getPointAtLength(t)}var t=$(n.el,n.svg),a=r(),o=r(-1),u=r(1);switch(n.property){case"x":return(a.x-t.x)*t.w;case"y":return(a.y-t.y)*t.h;case"angle":return 180*Math.atan2(u.y-o.y,u.x-o.x)/Math.PI}}function Y(n,e){var r=/-?\d*\.?\d+/g,t=L(i.pth(n)?n.totalLength:n,e)+"";return{original:t,numbers:t.match(r)?t.match(r).map(Number):[0],strings:i.str(n)||e?t.split(r):[]}}function Z(n){return m(n?y(i.arr(n)?n.map(b):b(n)):[],function(n,e,r){return r.indexOf(n)===e})}function Q(n){var e=Z(n);return e.map(function(n,r){return{target:n,id:r,total:e.length,transforms:{list:E(n)}}})}function V(n,e){var r=x(e);if(/^spring/.test(r.easing)&&(r.duration=s(r.easing)),i.arr(n)){var t=n.length;2===t&&!i.obj(n[0])?n={value:n}:i.fnc(e.duration)||(r.duration=e.duration/t)}var a=i.arr(n)?n:[n];return a.map(function(n,r){var t=i.obj(n)&&!i.pth(n)?n:{value:n};return i.und(t.delay)&&(t.delay=r?0:e.delay),i.und(t.endDelay)&&(t.endDelay=r===a.length-1?e.endDelay:0),t}).map(function(n){return k(n,r)})}function z(n,e){var r=[],t=e.keyframes;for(var a in t&&(e=k(function(n){for(var e=m(y(n.map(function(n){return Object.keys(n)})),function(n){return i.key(n)}).reduce(function(n,e){return n.indexOf(e)<0&&n.push(e),n},[]),r={},t=function(t){var a=e[t];r[a]=n.map(function(n){var e={};for(var r in n)i.key(r)?r==a&&(e.value=n[r]):e[r]=n[r];return e})},a=0;a-1&&(_.splice(o,1),r=_.length)}else a.tick(e);t++}n()}else U=cancelAnimationFrame(U)}return n}();function rn(r){void 0===r&&(r={});var t,o=0,u=0,i=0,c=0,s=null;function f(n){var e=window.Promise&&new Promise(function(n){return s=n});return n.finished=e,e}var l,d,p,h,v,g,y,b,M=(d=w(n,l=r),p=w(e,l),h=z(p,l),v=Q(l.targets),g=W(v,h),y=J(g,p),b=K,K++,k(d,{id:b,children:[],animatables:v,animations:g,duration:y.duration,delay:y.delay,endDelay:y.endDelay}));f(M);function x(){var n=M.direction;"alternate"!==n&&(M.direction="normal"!==n?"normal":"reverse"),M.reversed=!M.reversed,t.forEach(function(n){return n.reversed=M.reversed})}function O(n){return M.reversed?M.duration-n:n}function C(){o=0,u=O(M.currentTime)*(1/rn.speed)}function B(n,e){e&&e.seek(n-e.timelineOffset)}function P(n){for(var e=0,r=M.animations,t=r.length;e2||(b=Math.round(b*p)/p)),h.push(b)}var k=d.length;if(k){g=d[0];for(var O=0;O0&&(M.began=!0,I("begin")),!M.loopBegan&&M.currentTime>0&&(M.loopBegan=!0,I("loopBegin")),d<=r&&0!==M.currentTime&&P(0),(d>=l&&M.currentTime!==e||!e)&&P(e),d>r&&d=e&&(u=0,M.remaining&&!0!==M.remaining&&M.remaining--,M.remaining?(o=i,I("loopComplete"),M.loopBegan=!1,"alternate"===M.direction&&x()):(M.paused=!0,M.completed||(M.completed=!0,I("loopComplete"),I("complete"),!M.passThrough&&"Promise"in window&&(s(),f(M)))))}return M.reset=function(){var n=M.direction;M.passThrough=!1,M.currentTime=0,M.progress=0,M.paused=!0,M.began=!1,M.loopBegan=!1,M.changeBegan=!1,M.completed=!1,M.changeCompleted=!1,M.reversePlayback=!1,M.reversed="reverse"===n,M.remaining=M.loop,t=M.children;for(var e=c=t.length;e--;)M.children[e].reset();(M.reversed&&!0!==M.loop||"alternate"===n&&1===M.loop)&&M.remaining++,P(M.reversed?M.duration:0)},M.set=function(n,e){return R(n,e),M},M.tick=function(n){i=n,o||(o=i),T((i+(u-o))*rn.speed)},M.seek=function(n){T(O(n))},M.pause=function(){M.paused=!0,C()},M.play=function(){M.paused&&(M.completed&&M.reset(),M.paused=!1,_.push(M),C(),U||en())},M.reverse=function(){x(),C()},M.restart=function(){M.reset(),M.play()},M.reset(),M.autoplay&&M.play(),M}function tn(n,e){for(var r=e.length;r--;)M(n,e[r].animatable.target)&&e.splice(r,1)}return"undefined"!=typeof document&&document.addEventListener("visibilitychange",function(){document.hidden?(_.forEach(function(n){return n.pause()}),nn=_.slice(0),_=[]):nn.forEach(function(n){return n.play()})}),rn.version="3.0.1",rn.speed=1,rn.running=_,rn.remove=function(n){for(var e=Z(n),r=_.length;r--;){var t=_[r],a=t.animations,o=t.children;tn(e,a);for(var u=o.length;u--;){var i=o[u],c=i.animations;tn(e,c),c.length||i.children.length||o.splice(u,1)}a.length||o.length||t.pause()}},rn.get=N,rn.set=R,rn.convertPx=I,rn.path=function(n,e){var r=i.str(n)?g(n)[0]:n,t=e||100;return function(n){return{property:n,el:r,svg:$(r),totalLength:q(r)*(t/100)}}},rn.setDashoffset=function(n){var e=q(n);return n.setAttribute("stroke-dasharray",e),e},rn.stagger=function(n,e){void 0===e&&(e={});var r=e.direction||"normal",t=e.easing?v(e.easing):null,a=e.grid,o=e.axis,u=e.from||0,c="first"===u,s="center"===u,f="last"===u,l=i.arr(n),d=l?parseFloat(n[0]):parseFloat(n),p=l?parseFloat(n[1]):0,h=C(l?n[1]:n)||0,g=e.start||0+(l?d:0),m=[],y=0;return function(n,e,i){if(c&&(u=0),s&&(u=(i-1)/2),f&&(u=i-1),!m.length){for(var v=0;v-1&&_.splice(o,1);for(var s=0;s-1}function u(n,e){return n.apply(null,e)}var i={arr:function(n){return Array.isArray(n)},obj:function(n){return o(Object.prototype.toString.call(n),"Object")},pth:function(n){return i.obj(n)&&n.hasOwnProperty("totalLength")},svg:function(n){return n instanceof SVGElement},inp:function(n){return n instanceof HTMLInputElement},dom:function(n){return n.nodeType||i.svg(n)},str:function(n){return"string"==typeof n},fnc:function(n){return"function"==typeof n},und:function(n){return void 0===n},hex:function(n){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(n)},rgb:function(n){return/^rgb/.test(n)},hsl:function(n){return/^hsl/.test(n)},col:function(n){return i.hex(n)||i.rgb(n)||i.hsl(n)},key:function(r){return!n.hasOwnProperty(r)&&!e.hasOwnProperty(r)&&"targets"!==r&&"keyframes"!==r}};function c(n){var e=/\(([^)]+)\)/.exec(n);return e?e[1].split(",").map(function(n){return parseFloat(n)}):[]}function s(n,e){var r=c(n),o=a(i.und(r[0])?1:r[0],.1,100),u=a(i.und(r[1])?100:r[1],.1,100),s=a(i.und(r[2])?10:r[2],.1,100),f=a(i.und(r[3])?0:r[3],.1,100),l=Math.sqrt(u/o),d=s/(2*Math.sqrt(u*o)),p=d<1?l*Math.sqrt(1-d*d):0,h=1,v=d<1?(d*l-f)/p:-f+l;function g(n){var r=e?e*n/1e3:n;return r=d<1?Math.exp(-r*d*l)*(h*Math.cos(p*r)+v*Math.sin(p*r)):(h+v*r)*Math.exp(-r*l),0===n||1===n?n:1-r}return e?g:function(){var e=t.springs[n];if(e)return e;for(var r=0,a=0;;)if(1===g(r+=1/6)){if(++a>=16)break}else a=0;var o=r*(1/6)*1e3;return t.springs[n]=o,o}}function f(n){return void 0===n&&(n=10),function(e){return Math.round(e*n)*(1/n)}}var l,d,p=function(){var n=11,e=1/(n-1);function r(n,e){return 1-3*e+3*n}function t(n,e){return 3*e-6*n}function a(n){return 3*n}function o(n,e,o){return((r(e,o)*n+t(e,o))*n+a(e))*n}function u(n,e,o){return 3*r(e,o)*n*n+2*t(e,o)*n+a(e)}return function(r,t,a,i){if(0<=r&&r<=1&&0<=a&&a<=1){var c=new Float32Array(n);if(r!==t||a!==i)for(var s=0;s=.001?function(n,e,r,t){for(var a=0;a<4;++a){var i=u(e,r,t);if(0===i)return e;e-=(o(e,r,t)-n)/i}return e}(t,l,r,a):0===d?l:function(n,e,r,t,a){for(var u,i,c=0;(u=o(i=e+(r-e)/2,t,a)-n)>0?r=i:e=i,Math.abs(u)>1e-7&&++c<10;);return i}(t,i,i+e,r,a)}}}(),h=(l={linear:function(){return function(n){return n}}},d={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var e,r=4;n<((e=Math.pow(2,--r))-1)/11;);return 1/Math.pow(4,3-r)-7.5625*Math.pow((3*e-2)/22-n,2)}},Elastic:function(n,e){void 0===n&&(n=1),void 0===e&&(e=.5);var r=a(n,1,10),t=a(e,.1,2);return function(n){return 0===n||1===n?n:-r*Math.pow(2,10*(n-1))*Math.sin((n-1-t/(2*Math.PI)*Math.asin(1/r))*(2*Math.PI)/t)}}},["Quad","Cubic","Quart","Quint","Expo"].forEach(function(n,e){d[n]=function(){return function(n){return Math.pow(n,e+2)}}}),Object.keys(d).forEach(function(n){var e=d[n];l["easeIn"+n]=e,l["easeOut"+n]=function(n,r){return function(t){return 1-e(n,r)(1-t)}},l["easeInOut"+n]=function(n,r){return function(t){return t<.5?e(n,r)(2*t)/2:1-e(n,r)(-2*t+2)/2}}}),l);function v(n,e){if(i.fnc(n))return n;var r=n.split("(")[0],t=h[r],a=c(n);switch(r){case"spring":return s(n,e);case"cubicBezier":return u(p,a);case"steps":return u(f,a);default:return u(t,a)}}function g(n){try{return document.querySelectorAll(n)}catch(n){return}}function m(n,e){for(var r=n.length,t=arguments.length>=2?arguments[1]:void 0,a=[],o=0;o1&&(r-=1),r<1/6?n+6*(e-n)*r:r<.5?e:r<2/3?n+(e-n)*(2/3-r)*6:n}if(0==u)e=r=t=i;else{var f=i<.5?i*(1+u):i+u-i*u,l=2*i-f;e=s(l,f,o+1/3),r=s(l,f,o),t=s(l,f,o-1/3)}return"rgba("+255*e+","+255*r+","+255*t+","+c+")"}(n):void 0;var e,r,t,a}function C(n){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(n);if(e)return e[1]}function B(n,e){return i.fnc(n)?n(e.target,e.id,e.total):n}function P(n,e){return n.getAttribute(e)}function I(n,e,r){if(M([r,"deg","rad","turn"],C(e)))return e;var a=t.CSS[e+r];if(!i.und(a))return a;var o=document.createElement(n.tagName),u=n.parentNode&&n.parentNode!==document?n.parentNode:document.body;u.appendChild(o),o.style.position="absolute",o.style.width=100+r;var c=100/o.offsetWidth;u.removeChild(o);var s=c*parseFloat(e);return t.CSS[e+r]=s,s}function T(n,e,r){if(e in n.style){var t=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),a=n.style[e]||getComputedStyle(n).getPropertyValue(t)||"0";return r?I(n,a,r):a}}function D(n,e){return i.dom(n)&&!i.inp(n)&&(P(n,e)||i.svg(n)&&n[e])?"attribute":i.dom(n)&&M(r,e)?"transform":i.dom(n)&&"transform"!==e&&T(n,e)?"css":null!=n[e]?"object":void 0}function E(n){if(i.dom(n)){for(var e,r=n.style.transform||"",t=/(\w+)\(([^)]*)\)/g,a=new Map;e=t.exec(r);)a.set(e[1],e[2]);return a}}function F(n,e,r,t){var a,u=o(e,"scale")?1:0+(o(a=e,"translate")||"perspective"===a?"px":o(a,"rotate")||o(a,"skew")?"deg":void 0),i=E(n).get(e)||u;return r&&(r.transforms.list.set(e,i),r.transforms.last=e),t?I(n,i,t):i}function N(n,e,r,t){switch(D(n,e)){case"transform":return F(n,e,t,r);case"css":return T(n,e,r);case"attribute":return P(n,e);default:return n[e]||0}}function A(n,e){var r=/^(\*=|\+=|-=)/.exec(n);if(!r)return n;var t=C(n)||0,a=parseFloat(e),o=parseFloat(n.replace(r[0],""));switch(r[0][0]){case"+":return a+o+t;case"-":return a-o+t;case"*":return a*o+t}}function L(n,e){if(i.col(n))return O(n);if(/\s/g.test(n))return n;var r=C(n),t=r?n.substr(0,n.length-r.length):n;return e?t+e:t}function j(n,e){return Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2))}function S(n){for(var e,r=n.points,t=0,a=0;a0&&(t+=j(e,o)),e=o}return t}function q(n){if(n.getTotalLength)return n.getTotalLength();switch(n.tagName.toLowerCase()){case"circle":return o=n,2*Math.PI*P(o,"r");case"rect":return 2*P(a=n,"width")+2*P(a,"height");case"line":return j({x:P(t=n,"x1"),y:P(t,"y1")},{x:P(t,"x2"),y:P(t,"y2")});case"polyline":return S(n);case"polygon":return r=(e=n).points,S(e)+j(r.getItem(r.numberOfItems-1),r.getItem(0))}var e,r,t,a,o}function $(n,e){var r=e||{},t=r.el||function(n){for(var e=n.parentNode;i.svg(e)&&i.svg(e.parentNode);)e=e.parentNode;return e}(n),a=t.getBoundingClientRect(),o=P(t,"viewBox"),u=a.width,c=a.height,s=r.viewBox||(o?o.split(" "):[0,0,u,c]);return{el:t,viewBox:s,x:s[0]/1,y:s[1]/1,w:u/s[2],h:c/s[3]}}function X(n,e){function r(r){void 0===r&&(r=0);var t=e+r>=1?e+r:0;return n.el.getPointAtLength(t)}var t=$(n.el,n.svg),a=r(),o=r(-1),u=r(1);switch(n.property){case"x":return(a.x-t.x)*t.w;case"y":return(a.y-t.y)*t.h;case"angle":return 180*Math.atan2(u.y-o.y,u.x-o.x)/Math.PI}}function Y(n,e){var r=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,t=L(i.pth(n)?n.totalLength:n,e)+"";return{original:t,numbers:t.match(r)?t.match(r).map(Number):[0],strings:i.str(n)||e?t.split(r):[]}}function Z(n){return m(n?y(i.arr(n)?n.map(b):b(n)):[],function(n,e,r){return r.indexOf(n)===e})}function Q(n){var e=Z(n);return e.map(function(n,r){return{target:n,id:r,total:e.length,transforms:{list:E(n)}}})}function V(n,e){var r=x(e);if(/^spring/.test(r.easing)&&(r.duration=s(r.easing)),i.arr(n)){var t=n.length;2===t&&!i.obj(n[0])?n={value:n}:i.fnc(e.duration)||(r.duration=e.duration/t)}var a=i.arr(n)?n:[n];return a.map(function(n,r){var t=i.obj(n)&&!i.pth(n)?n:{value:n};return i.und(t.delay)&&(t.delay=r?0:e.delay),i.und(t.endDelay)&&(t.endDelay=r===a.length-1?e.endDelay:0),t}).map(function(n){return k(n,r)})}function z(n,e){var r=[],t=e.keyframes;for(var a in t&&(e=k(function(n){for(var e=m(y(n.map(function(n){return Object.keys(n)})),function(n){return i.key(n)}).reduce(function(n,e){return n.indexOf(e)<0&&n.push(e),n},[]),r={},t=function(t){var a=e[t];r[a]=n.map(function(n){var e={};for(var r in n)i.key(r)?r==a&&(e.value=n[r]):e[r]=n[r];return e})},a=0;a-1&&(_.splice(o,1),r=_.length)}else a.tick(e);t++}n()}else U=cancelAnimationFrame(U)}return n}();function rn(r){void 0===r&&(r={});var t,o=0,u=0,i=0,c=0,s=null;function f(n){var e=window.Promise&&new Promise(function(n){return s=n});return n.finished=e,e}var l,d,p,h,v,g,y,b,M=(d=w(n,l=r),p=w(e,l),h=z(p,l),v=Q(l.targets),g=W(v,h),y=J(g,p),b=K,K++,k(d,{id:b,children:[],animatables:v,animations:g,duration:y.duration,delay:y.delay,endDelay:y.endDelay}));f(M);function x(){var n=M.direction;"alternate"!==n&&(M.direction="normal"!==n?"normal":"reverse"),M.reversed=!M.reversed,t.forEach(function(n){return n.reversed=M.reversed})}function O(n){return M.reversed?M.duration-n:n}function C(){o=0,u=O(M.currentTime)*(1/rn.speed)}function B(n,e){e&&e.seek(n-e.timelineOffset)}function P(n){for(var e=0,r=M.animations,t=r.length;e2||(b=Math.round(b*p)/p)),h.push(b)}var k=d.length;if(k){g=d[0];for(var O=0;O0&&(M.began=!0,I("begin")),!M.loopBegan&&M.currentTime>0&&(M.loopBegan=!0,I("loopBegin")),d<=r&&0!==M.currentTime&&P(0),(d>=l&&M.currentTime!==e||!e)&&P(e),d>r&&d=e&&(u=0,M.remaining&&!0!==M.remaining&&M.remaining--,M.remaining?(o=i,I("loopComplete"),M.loopBegan=!1,"alternate"===M.direction&&x()):(M.paused=!0,M.completed||(M.completed=!0,I("loopComplete"),I("complete"),!M.passThrough&&"Promise"in window&&(s(),f(M)))))}return M.reset=function(){var n=M.direction;M.passThrough=!1,M.currentTime=0,M.progress=0,M.paused=!0,M.began=!1,M.loopBegan=!1,M.changeBegan=!1,M.completed=!1,M.changeCompleted=!1,M.reversePlayback=!1,M.reversed="reverse"===n,M.remaining=M.loop,t=M.children;for(var e=c=t.length;e--;)M.children[e].reset();(M.reversed&&!0!==M.loop||"alternate"===n&&1===M.loop)&&M.remaining++,P(M.reversed?M.duration:0)},M.set=function(n,e){return R(n,e),M},M.tick=function(n){i=n,o||(o=i),T((i+(u-o))*rn.speed)},M.seek=function(n){T(O(n))},M.pause=function(){M.paused=!0,C()},M.play=function(){M.paused&&(M.completed&&M.reset(),M.paused=!1,_.push(M),C(),U||en())},M.reverse=function(){x(),C()},M.restart=function(){M.reset(),M.play()},M.reset(),M.autoplay&&M.play(),M}function tn(n,e){for(var r=e.length;r--;)M(n,e[r].animatable.target)&&e.splice(r,1)}return"undefined"!=typeof document&&document.addEventListener("visibilitychange",function(){document.hidden?(_.forEach(function(n){return n.pause()}),nn=_.slice(0),_=[]):nn.forEach(function(n){return n.play()})}),rn.version="3.0.1",rn.speed=1,rn.running=_,rn.remove=function(n){for(var e=Z(n),r=_.length;r--;){var t=_[r],a=t.animations,o=t.children;tn(e,a);for(var u=o.length;u--;){var i=o[u],c=i.animations;tn(e,c),c.length||i.children.length||o.splice(u,1)}a.length||o.length||t.pause()}},rn.get=N,rn.set=R,rn.convertPx=I,rn.path=function(n,e){var r=i.str(n)?g(n)[0]:n,t=e||100;return function(n){return{property:n,el:r,svg:$(r),totalLength:q(r)*(t/100)}}},rn.setDashoffset=function(n){var e=q(n);return n.setAttribute("stroke-dasharray",e),e},rn.stagger=function(n,e){void 0===e&&(e={});var r=e.direction||"normal",t=e.easing?v(e.easing):null,a=e.grid,o=e.axis,u=e.from||0,c="first"===u,s="center"===u,f="last"===u,l=i.arr(n),d=l?parseFloat(n[0]):parseFloat(n),p=l?parseFloat(n[1]):0,h=C(l?n[1]:n)||0,g=e.start||0+(l?d:0),m=[],y=0;return function(n,e,i){if(c&&(u=0),s&&(u=(i-1)/2),f&&(u=i-1),!m.length){for(var v=0;v-1&&_.splice(o,1);for(var s=0;s Date: Thu, 25 Jul 2019 10:46:55 +0200 Subject: [PATCH 23/34] Uodpate complex properties example --- documentation/examples/anime-complex-properties.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/examples/anime-complex-properties.html b/documentation/examples/anime-complex-properties.html index 23484bfc..3ce5e49e 100644 --- a/documentation/examples/anime-complex-properties.html +++ b/documentation/examples/anime-complex-properties.html @@ -90,14 +90,14 @@ }); var unitLess = anime({ targets: '.unit-less', - borderRadius: 10, + borderRadius: 16, loop: true, direction: 'alternate', easing: 'linear' }); var specifiedUnit = anime({ targets: '.specified-unit', - borderRadius: ['16px', '1em'], + borderRadius: '1em', loop: true, direction: 'alternate', easing: 'linear' From f7dd758b760364961b91248846dc2cccc6a0085f Mon Sep 17 00:00:00 2001 From: Julian Garnier Date: Thu, 25 Jul 2019 10:52:01 +0200 Subject: [PATCH 24/34] Update complex properties examples --- .../examples/anime-complex-properties.html | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/documentation/examples/anime-complex-properties.html b/documentation/examples/anime-complex-properties.html index 3ce5e49e..ace93b8e 100644 --- a/documentation/examples/anime-complex-properties.html +++ b/documentation/examples/anime-complex-properties.html @@ -105,81 +105,81 @@ var filter = anime({ targets: '.filter', filter: ["blur(20px)", "blur(0px)"], - // loop: true, - // direction: 'alternate', + 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', + loop: true, + direction: 'alternate', easing: 'linear' }); var calc = anime({ targets: '.calc', height: ['calc(25% - 100px)', 'calc(25% - 0px)'], - // loop: true, - // direction: 'alternate', + loop: true, + direction: 'alternate', easing: 'linear' }); var zeroValue = anime({ targets: '.zero-value', scale: 0, - // loop: true, - // direction: 'alternate', + loop: true, + direction: 'alternate', easing: 'linear' }); var roundValue = anime({ targets: '.round-value', translateY: 100, round: .1, - // loop: true, - // direction: 'alternate', + loop: true, + direction: 'alternate', easing: 'linear' }); var clipPath = anime({ targets: '.clip-path', clipPath: ['circle(0px at center)', 'circle(100px at center)'], - // loop: true, - // direction: 'alternate', + loop: true, + direction: 'alternate', easing: 'linear' }); var svgTransform = anime({ targets: 'rect', transform: 'translate(10 10) scale(2)', - // loop: true, - // direction: 'alternate', + loop: true, + direction: 'alternate', easing: 'linear' }); var rangeValue = anime({ - targets: 'input', + targets: 'input[type="range"]', value: 100, - // loop: true, - // direction: 'alternate', + loop: true, + direction: 'alternate', easing: 'linear' }); var basicCSS = anime({ targets: '.basic-css', width: 50, height: 50, - // loop: true, - // direction: 'alternate', + loop: true, + direction: 'alternate', easing: 'linear' }); var autoProperty = anime({ targets: '.auto-property', backgroundSize: ['auto 10px', 'auto 400px'], margin: '20% 40px 10px 30px', - // loop: true, - // direction: 'alternate', + loop: true, + direction: 'alternate', easing: 'linear' }); var exponentValues = anime({ targets: '.exponent-values', value: '+1.0123456789012346e+21px', - // loop: true, - // direction: 'alternate', + loop: true, + direction: 'alternate', easing: 'linear' }); From 8e884cd7adacebe66d185a64fb424ea1cc0628f9 Mon Sep 17 00:00:00 2001 From: Julian Garnier Date: Thu, 25 Jul 2019 10:57:52 +0200 Subject: [PATCH 25/34] Update anime-callbacks.html --- documentation/examples/anime-callbacks.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/examples/anime-callbacks.html b/documentation/examples/anime-callbacks.html index 48ea5e5a..afc75988 100644 --- a/documentation/examples/anime-callbacks.html +++ b/documentation/examples/anime-callbacks.html @@ -26,7 +26,7 @@ position: absolute; width: 100%; height: 100vh; - padding-bottom: 50vh; + padding-bottom: 128px; } .el { @@ -93,7 +93,7 @@ .timeline { position: fixed; bottom: 0; - height: 50vh; + height: 128px; padding-top: 4px; background-color: #000; } From b48016b96c7e18b55a4d1d64b7fc08649feea3ef Mon Sep 17 00:00:00 2001 From: Julian Garnier Date: Thu, 25 Jul 2019 11:19:30 +0200 Subject: [PATCH 26/34] Update examples --- documentation/examples/advanced-staggering-2.html | 5 +++-- documentation/examples/advanced-staggering.html | 5 +++-- documentation/examples/anime-DOM-stress-test.html | 5 +++-- documentation/examples/anime-callbacks.html | 5 +++-- documentation/examples/anime-colors-test.html | 4 ++-- documentation/examples/anime-complex-properties.html | 2 +- documentation/examples/anime-direction-reverse.html | 5 +++-- documentation/examples/anime-directions-testing.html | 4 ++-- documentation/examples/anime-ease-visualizer.html | 4 ++-- documentation/examples/anime-follow-scroll.html | 5 +++-- documentation/examples/anime-keyframes.html | 5 +++-- documentation/examples/anime-mgs-logo-animation.html | 4 ++-- documentation/examples/anime-reverse.html | 5 +++-- documentation/examples/anime-speed-test.html | 4 ++-- documentation/examples/anime-stagger-demo.html | 5 +++-- documentation/examples/anime-stagger-grid-demo.html | 5 +++-- documentation/examples/anime-stagger-tests.html | 5 +++-- documentation/examples/anime-stagger.html | 5 +++-- documentation/examples/anime-staggered-animations.html | 4 ++-- documentation/examples/anime-staggering-demo.html | 5 +++-- documentation/examples/anime-svg-lines-animations.html | 4 ++-- documentation/examples/anime-svg-path-animation.html | 4 ++-- documentation/examples/anime-timeline-stresstest.html | 5 +++-- documentation/examples/anime-timeline.html | 5 +++-- documentation/examples/anime-v2-logo-animation.html | 4 ++-- documentation/examples/anime-v3-logo-animation.html | 4 ++-- documentation/examples/built-in-easings-2.html | 4 ++-- documentation/examples/built-in-easings.html | 4 ++-- documentation/examples/layered-animations.html | 4 ++-- documentation/examples/time-control.html | 4 ++-- documentation/examples/transforms-demo.html | 4 ++-- 31 files changed, 76 insertions(+), 61 deletions(-) diff --git a/documentation/examples/advanced-staggering-2.html b/documentation/examples/advanced-staggering-2.html index 172c77ef..bb7ef4e1 100644 --- a/documentation/examples/advanced-staggering-2.html +++ b/documentation/examples/advanced-staggering-2.html @@ -13,9 +13,10 @@ - - + + + @@ -67,7 +66,7 @@
-
+
@@ -75,75 +74,86 @@ import anime from '../../src/index.js'; - const staggerVisualizerEl = document.querySelector('.stagger-visualizer'); - const fragment = document.createDocumentFragment(); - const numberOfElements = 24*11; - - for (let i = 0; i < numberOfElements; i++) { - const dotEl = document.createElement('div'); - dotEl.classList.add('dot'); - fragment.appendChild(dotEl); - } - - staggerVisualizerEl.appendChild(fragment); - - let index = anime.random(0, numberOfElements); - let nextIndex = 0; - - function animateGrid() { - - nextIndex = anime.random(0, numberOfElements); - - anime.set('.cursor', { - translateX: anime.stagger('-38px', {grid: [24, 11], from: index, axis: 'x'}), - translateY: anime.stagger('-38px', {grid: [24, 11], from: index, axis: 'y'}) - }); - anime.timeline({ - easing: 'easeInOutQuad', - complete: animateGrid - }) - .add({ - targets: '.cursor', - keyframes: [ - { scale: .625 }, - { scale: 1.125 }, - { scale: 1 } - ], - duration: 600 - }) - .add({ - targets: '.dot', - keyframes: [ - { - translateX: anime.stagger('-4px', {grid: [24, 11], from: index, axis: 'x'}), - translateY: anime.stagger('-4px', {grid: [24, 11], from: index, axis: 'y'}), - duration: 200 - }, { - translateX: anime.stagger('4px', {grid: [24, 11], from: index, axis: 'x'}), - translateY: anime.stagger('4px', {grid: [24, 11], from: index, axis: 'y'}), - scale: anime.stagger([9, 2], {grid: [24, 11], from: index}), - duration: 400 - }, { - translateX: 0, - translateY: 0, - scale: 1, - duration: 600, - } - ], - delay: anime.stagger(30, {grid: [24, 11], from: index}) - }, '-=600') - .add({ - targets: '.cursor', - translateX: { value: anime.stagger('-38px', {grid: [24, 11], from: nextIndex, axis: 'x'}), duration: anime.random(400, 1200) }, - translateY: { value: anime.stagger('-38px', {grid: [24, 11], from: nextIndex, axis: 'y'}), duration: anime.random(400, 1200) }, - easing: 'easeOutSine' - }, '-=1100') - - index = nextIndex; - - } - - animateGrid(); + + var advancedStaggeringAnimation = (function() { + + var staggerVisualizerEl = document.querySelector('.stagger-visualizer'); + var dotsWrapperEl = staggerVisualizerEl.querySelector('.dots-wrapper'); + var dotsFragment = document.createDocumentFragment(); + var grid = [32, 16]; + var cellSize = 1; + var numberOfElements = grid[0] * grid[1]; + var animation; + var paused = true; + + for (var i = 0; i < numberOfElements; i++) { + var dotEl = document.createElement('div'); + dotEl.classList.add('dot'); + dotsFragment.appendChild(dotEl); + } + + dotsWrapperEl.appendChild(dotsFragment); + + var index = anime.random(0, numberOfElements-1); + var nextIndex = 0; + + function play() { + + paused = false; + if (animation) animation.pause(); + + nextIndex = anime.random(0, numberOfElements-1); + + var saturation = 75; + + var colorStart = anime.random(0, 256); + var colorEnd = anime.random(0, 256); + var colorRangeValue = [colorStart, colorEnd]; + var luminosityStart = anime.random(60, 80); + var luminosityEnd = anime.random(20, 40); + var luminosityRangeValue = [luminosityStart, luminosityEnd]; + + function staggeredGridColors(el, i, total) { + var hue = Math.round(anime.stagger(colorRangeValue, {grid: grid, from: index})(el, i, total)); + var luminosity = Math.round(anime.stagger(luminosityRangeValue, {grid: grid, from: index})(el, i, total)); + return 'hsl(' + hue + ', ' + saturation + '%, ' + luminosity + '%)'; + } + + animation = anime({ + targets: '.stagger-visualizer .dot', + keyframes: [ + { + zIndex: function(el, i, total) { + return Math.round(anime.stagger([numberOfElements, 0], {grid: grid, from: index})(el, i, total)); + }, + translateX: anime.stagger('-.001rem', {grid: grid, from: index, axis: 'x'}), + translateY: anime.stagger('-.001rem', {grid: grid, from: index, axis: 'y'}), + duration: 200 + }, { + translateX: anime.stagger('.075rem', {grid: grid, from: index, axis: 'x'}), + translateY: anime.stagger('.075rem', {grid: grid, from: index, axis: 'y'}), + scale: anime.stagger([2, .2], {grid: grid, from: index}), + backgroundColor: staggeredGridColors, + duration: 450 + }, { + translateX: 0, + translateY: 0, + scale: 1, + duration: 500, + } + ], + delay: anime.stagger(60, {grid: grid, from: index}), + easing: 'easeInOutQuad', + complete: play + }, 30) + + index = nextIndex; + + } + + play(); + + })(); From 4a6f54d6224ad7886ed81072314b6f86c3794911 Mon Sep 17 00:00:00 2001 From: Julian Garnier Date: Thu, 25 Jul 2019 14:50:27 +0200 Subject: [PATCH 28/34] Update ease-visualizer --- .../examples/advanced-staggering.html | 6 +- .../examples/anime-direction-reverse.html | 93 ------ .../examples/anime-directions-testing.html | 13 +- .../examples/anime-ease-visualizer.html | 269 ++++++++++++------ 4 files changed, 191 insertions(+), 190 deletions(-) delete mode 100644 documentation/examples/anime-direction-reverse.html diff --git a/documentation/examples/advanced-staggering.html b/documentation/examples/advanced-staggering.html index f5104847..957ead46 100644 --- a/documentation/examples/advanced-staggering.html +++ b/documentation/examples/advanced-staggering.html @@ -77,6 +77,7 @@ const staggerVisualizerEl = document.querySelector('.stagger-visualizer'); const fragment = document.createDocumentFragment(); const numberOfElements = 16*16; + var animation; for (let i = 0; i < numberOfElements; i++) { const dotEl = document.createElement('div'); @@ -91,13 +92,16 @@ function animateGrid() { + if (animation) animation.pause(); + nextIndex = anime.random(0, numberOfElements); anime.set('.cursor', { translateX: anime.stagger('-1rem', {grid: [16, 16], from: index, axis: 'x'}), translateY: anime.stagger('-1rem', {grid: [16, 16], from: index, axis: 'y'}) }); - anime.timeline({ + + animation = anime.timeline({ easing: 'easeInOutQuad', complete: animateGrid }) diff --git a/documentation/examples/anime-direction-reverse.html b/documentation/examples/anime-direction-reverse.html deleted file mode 100644 index 86722583..00000000 --- a/documentation/examples/anime-direction-reverse.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - Direction reverse | anime.js - - - - - - - - - - - - - - - - - - - - - -
- -
-
01
-
02
-
03
-
04
-
05
-
06
-
07
-
08
-
09
-
10
-
11
-
12
-
13
-
14
-
- - - - - diff --git a/documentation/examples/anime-directions-testing.html b/documentation/examples/anime-directions-testing.html index 6e7bd7f2..47b56b44 100644 --- a/documentation/examples/anime-directions-testing.html +++ b/documentation/examples/anime-directions-testing.html @@ -15,6 +15,7 @@ + - - - -
- - - - diff --git a/documentation/examples/anime-stagger-grid-demo.html b/documentation/examples/anime-stagger-grid-demo.html index ecabcf0d..26e9d1ec 100644 --- a/documentation/examples/anime-stagger-grid-demo.html +++ b/documentation/examples/anime-stagger-grid-demo.html @@ -36,8 +36,8 @@ flex-wrap: wrap; justify-content: center; align-items: center; - width: 20rem; - height: 20rem; + width: 17rem; + height: 17rem; } .stagger-visualizer div { @@ -61,7 +61,10 @@ const staggerVisualizerEl = document.querySelector('.stagger-visualizer'); const fragment = document.createDocumentFragment(); - const numberOfElements = 400; + const grid = [17, 17]; + const col = grid[0]; + const row = grid[1]; + const numberOfElements = col * row; for (let i = 0; i < numberOfElements; i++) { fragment.appendChild(document.createElement('div')); @@ -74,59 +77,51 @@ easing: 'easeInOutSine', delay: anime.stagger(50), loop: true, - direction: 'alternate', - autoplay: false, - loopComplete: (a) => console.log('end'), - //update: () => console.log(staggersAnimation.progress) + autoplay: false }) .add({ translateX: [ - {value: anime.stagger('-.1rem', {grid: [20, 20], from: 'center', axis: 'x'}) }, - {value: anime.stagger('.1rem', {grid: [20, 20], from: 'center', axis: 'x'}) } + {value: anime.stagger('-.1rem', {grid: grid, from: 'center', axis: 'x'}) }, + {value: anime.stagger('.1rem', {grid: grid, from: 'center', axis: 'x'}) } ], translateY: [ - {value: anime.stagger('-.1rem', {grid: [20, 20], from: 'center', axis: 'y'}) }, - {value: anime.stagger('.1rem', {grid: [20, 20], from: 'center', axis: 'y'}) } + {value: anime.stagger('-.1rem', {grid: grid, from: 'center', axis: 'y'}) }, + {value: anime.stagger('.1rem', {grid: grid, from: 'center', axis: 'y'}) } ], duration: 1000, scale: .5, - delay: anime.stagger(100, {grid: [20, 20], from: 'center'}) + delay: anime.stagger(100, {grid: grid, from: 'center'}) }) .add({ translateX: () => anime.random(-10, 10), translateY: () => anime.random(-10, 10), - delay: anime.stagger(2, {from: 'last'}) + delay: anime.stagger(8, {from: 'last'}) }) .add({ - translateX: 0, - translateY: anime.stagger('.5rem', {grid: [20, 20], from: 'center', axis: 'y'}), - rotate: anime.stagger(10, {grid: [20, 20], from: 'first', axis: 'y'}), - scale: anime.stagger([0,1], {grid: [20, 20], axis: 'y'}), - delay: anime.stagger(2, {from: 'center'}) - }) - .add({ - translateX: anime.stagger(['1rem', '-1rem'], {grid: [20, 20], from: 'center', axis: 'x'}), - translateY: anime.stagger(['1rem', '-1rem'], {grid: [20, 20], from: 'center', axis: 'y'}), + translateX: anime.stagger('.25rem', {grid: grid, from: 'center', axis: 'x'}), + translateY: anime.stagger('.25rem', {grid: grid, from: 'center', axis: 'y'}), rotate: 0, - delay: anime.stagger(1, {from: 'last'}) + scaleX: 4, + scaleY: .25, + delay: anime.stagger(4, {from: 'center'}) }) .add({ - scaleX: 4, - translateX: anime.stagger('1rem', {grid: [20, 20], from: 'center', axis: 'x'}), - translateY: anime.stagger('1rem', {grid: [20, 20], from: 'center', axis: 'y'}), - delay: anime.stagger(10, {grid: [20, 20], from: 'last'}) + rotate: anime.stagger([90, 0], {grid: grid, from: 'center'}), + delay: anime.stagger(50, {grid: grid, from: 'center'}) }) .add({ - scaleX: 1, translateX: 0, translateY: 0, - rotate: anime.stagger([-360, 0], {grid: [20, 20]}), - delay: anime.stagger(50, {grid: [20, 20], from: 'center'}) + scale: .5, + scaleX: 1, + rotate: 0, + duration: 1000, + delay: anime.stagger(100, {grid: grid, from: 'center'}) }) .add({ - translateX: anime.stagger('1rem', {grid: [20, 20], from: 'center', axis: 'x'}), - translateY: anime.stagger('1rem', {grid: [20, 20], from: 'center', axis: 'y'}), - delay: anime.stagger(20, {grid: [20, 20]}) + scaleY: 1, + scale: 1, + delay: anime.stagger(20, {grid: grid, from: 'center'}) }) staggersAnimation.play(); From 5c105055f2598cea924a40d09b14671a05539c12 Mon Sep 17 00:00:00 2001 From: Julian Garnier Date: Thu, 25 Jul 2019 15:28:44 +0200 Subject: [PATCH 31/34] Update examples --- .../examples/anime-stagger-tests.html | 8 +- documentation/examples/anime-stagger.html | 428 ------------------ .../examples/anime-staggered-easing-demo.html | 90 ++++ .../examples/anime-staggering-demo.html | 155 ------- .../examples/anime-timeline-stresstest.html | 141 ------ .../examples/anime-v2-logo-animation.html | 5 +- .../examples/anime-v3-logo-animation.html | 158 ------- .../examples/built-in-easings-2.html | 135 ------ documentation/examples/built-in-easings.html | 48 +- documentation/examples/time-control.html | 2 +- documentation/examples/transforms-demo.html | 15 +- 11 files changed, 138 insertions(+), 1047 deletions(-) delete mode 100644 documentation/examples/anime-stagger.html create mode 100644 documentation/examples/anime-staggered-easing-demo.html delete mode 100644 documentation/examples/anime-staggering-demo.html delete mode 100644 documentation/examples/anime-timeline-stresstest.html delete mode 100644 documentation/examples/anime-v3-logo-animation.html delete mode 100644 documentation/examples/built-in-easings-2.html diff --git a/documentation/examples/anime-stagger-tests.html b/documentation/examples/anime-stagger-tests.html index 74995eee..6549ba0b 100644 --- a/documentation/examples/anime-stagger-tests.html +++ b/documentation/examples/anime-stagger-tests.html @@ -391,14 +391,14 @@

Coordinates reversed

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, { + anime.set(anim.player.animationEl, { left: convertMStoEM(timelineOffset) + 'em', width: convertMStoEM(anim.duration * 3) + 'em' }); - anime.setValue(anim.player.delayEl, {width: (anim.delay / anim.duration) * 100 + '%'}); - anime.setValue(anim.player.endDelayEl, {width: (anim.endDelay / anim.duration) * 100 + '%'}); + anime.set(anim.player.delayEl, {width: (anim.delay / anim.duration) * 100 + '%'}); + anime.set(anim.player.endDelayEl, {width: (anim.endDelay / anim.duration) * 100 + '%'}); } - anime.setValue(anim.player.animationEl, {color: colors[colorIndex]}); + anime.set(anim.player.animationEl, {color: colors[colorIndex]}); colorIndex++; if (!colors[colorIndex]) colorIndex = 0; anim.update(); diff --git a/documentation/examples/anime-stagger.html b/documentation/examples/anime-stagger.html deleted file mode 100644 index 32a010dd..00000000 --- a/documentation/examples/anime-stagger.html +++ /dev/null @@ -1,428 +0,0 @@ - - - - stager | anime.js - - - - - - - - - - - - - - - - - - - -
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
- -
-
- - - - diff --git a/documentation/examples/anime-staggered-easing-demo.html b/documentation/examples/anime-staggered-easing-demo.html new file mode 100644 index 00000000..0056c7d1 --- /dev/null +++ b/documentation/examples/anime-staggered-easing-demo.html @@ -0,0 +1,90 @@ + + + + stagger | anime.js + + + + + + + + + + + + + + + + + + + +
+ + + + diff --git a/documentation/examples/anime-staggering-demo.html b/documentation/examples/anime-staggering-demo.html deleted file mode 100644 index 7fd303fc..00000000 --- a/documentation/examples/anime-staggering-demo.html +++ /dev/null @@ -1,155 +0,0 @@ - - - - stagger | anime.js - - - - - - - - - - - - - - - - - - - -
- - - - diff --git a/documentation/examples/anime-timeline-stresstest.html b/documentation/examples/anime-timeline-stresstest.html deleted file mode 100644 index d6dd1daf..00000000 --- a/documentation/examples/anime-timeline-stresstest.html +++ /dev/null @@ -1,141 +0,0 @@ - - - - Anime timeline | anime.js - - - - - - - - - - - - - - - - - - - - -
-
-
- - - -
-
- -
-
- - - - diff --git a/documentation/examples/anime-v2-logo-animation.html b/documentation/examples/anime-v2-logo-animation.html index f74032b1..40dfad73 100644 --- a/documentation/examples/anime-v2-logo-animation.html +++ b/documentation/examples/anime-v2-logo-animation.html @@ -15,6 +15,7 @@ + @@ -245,7 +246,7 @@ easing: 'easeOutQuart' }, stroke: { - value: ['#FFF', function(el) { return anime.getValue(el.parentNode, 'stroke') } ], + value: ['#FFF', function(el) { return anime.get(el.parentNode, 'stroke') } ], duration: 500, delay: 500, easing: 'easeInQuad' @@ -302,7 +303,7 @@ easing: 'easeInQuad' }, stroke: { - value: ['#FFF', function(el) { return anime.getValue(el, 'stroke') } ], + value: ['#FFF', function(el) { return anime.get(el, 'stroke') } ], duration: 800, delay: 3400, easing: 'easeInQuad' diff --git a/documentation/examples/anime-v3-logo-animation.html b/documentation/examples/anime-v3-logo-animation.html deleted file mode 100644 index 663ce8f4..00000000 --- a/documentation/examples/anime-v3-logo-animation.html +++ /dev/null @@ -1,158 +0,0 @@ - - - - Anime logo animation | anime.js - - - - - - - - - - - - - - - - - - - -
- -
- -
- -
- -
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
- -
- - -
- - - - diff --git a/documentation/examples/built-in-easings-2.html b/documentation/examples/built-in-easings-2.html deleted file mode 100644 index 1023bc8e..00000000 --- a/documentation/examples/built-in-easings-2.html +++ /dev/null @@ -1,135 +0,0 @@ - - - - built-in easings • anime.js - - - - - - - - - - - - - - - - - - -
-
-
-
- - - - diff --git a/documentation/examples/built-in-easings.html b/documentation/examples/built-in-easings.html index f2d4a5c2..26adf817 100644 --- a/documentation/examples/built-in-easings.html +++ b/documentation/examples/built-in-easings.html @@ -16,6 +16,7 @@ +