JavaScript animation engine
Add springDuration for future implementation
Julian Garnier01e5ca941ea1
diff --git a/anime.js b/anime.jsindex 2b3e29c7..3d89a1dd 100644--- a/anime.js+++ b/anime.js@@ -541,12 +541,18 @@}const propArray = is.arr(prop) ? prop : [prop];return propArray.map((v, i) => {- // Default delay value should be applied only on the first tween- const delay = !i ? tweenSettings.delay : 0;- // Use path object as a tween value- let obj = is.obj(v) && !is.pth(v) ? v : {value: v};+ let obj;+ if (is.obj(v) && !is.pth(v)) {+ // Override hadDuration if no duration is specified in the object+ v.springDuration = is.und(v.duration) ? false : v.duration;+ obj = v;+ } else {+ // Path object are used as tween values+ obj = {value: v};+ }// Set default delay value- if (is.und(obj.delay)) obj.delay = delay;+ // Default delay value should be applied only on the first tween+ if (is.und(obj.delay)) obj.delay = !i ? tweenSettings.delay : 0;return obj;}).map(k => mergeObjects(k, settings));}@@ -682,6 +688,7 @@function createNewInstance(params) {const instanceSettings = replaceObjectProps(defaultInstanceSettings, params);const tweenSettings = replaceObjectProps(defaultTweenSettings, params);+ tweenSettings.springDuration = params.duration;const animatables = getAnimatables(params.targets);const properties = getProperties(instanceSettings, tweenSettings, params);const animations = getAnimations(animatables, properties);@@ -889,7 +896,7 @@instance.reversed = direction === 'reverse';instance.remaining = direction === 'alternate' && loops === 1 ? 2 : loops;setAnimationsProgress(0);- for (let i = instance.children.length; i--; ){+ for (let i = instance.children.length; i--; ) {instance.children[i].reset();}}diff --git a/documentation/examples/anime-tests.html b/documentation/examples/anime-tests.htmlindex 4bd5c120..b4990f6d 100644--- a/documentation/examples/anime-tests.html+++ b/documentation/examples/anime-tests.html@@ -48,6 +48,15 @@color01El.addEventListener('mouseleave', function() {anime({ targets: this, scale: 1 });}, false);+ var animation = anime({+ targets: '.color-02',+ duration: 500,+ scale: {+ value: 2,+ duration: 700+ }+ });+ console.log(animation.animations[0].tweens[0].hasDuration);</script></body></html>\ No newline at end of filediff --git a/documentation/examples/anime-timeline.html b/documentation/examples/anime-timeline.htmlindex 25df225c..7782b2b9 100644--- a/documentation/examples/anime-timeline.html+++ b/documentation/examples/anime-timeline.html@@ -263,8 +263,6 @@}).add({targets: ['.multiple-targets-01', '.multiple-targets-02', '.multiple-targets-03', '.multiple-targets-04'],- translateY: -100,- scale: 8,background: '#18FF92',duration: 500,begin: function() { console.log('multipleTargets animation 2 began')},@@ -272,8 +270,6 @@}, '-=250').add({targets: ['.multiple-targets-01', '.multiple-targets-02', '.multiple-targets-03', '.multiple-targets-04'],- translateY: -100,- scale: 8,background: '#5A87FF',duration: 500,begin: function() { console.log('multipleTargets animation 3 began')},@@ -281,8 +277,6 @@}, '-=250').add({targets: ['.multiple-targets-01', '.multiple-targets-02', '.multiple-targets-03', '.multiple-targets-04'],- translateY: -100,- scale: 8,background: '#FBF38C',duration: 500,begin: function() { console.log('multipleTargets animation 4 began')},@@ -290,7 +284,6 @@}, '-=250').add({targets: ['.multiple-targets-01', '.multiple-targets-02', '.multiple-targets-03', '.multiple-targets-04'],- translateY: -100,scale: 13,background: '#FBF38C',duration: 1000,