Skip to content

armgit / anime

Public Imported from GitHub
0

JavaScript animation engine

Add switchTo to states

Julian Garnier1c18b1fc552a
diff --git a/anime.js b/anime.js
index 1305efa6..9490dfb8 100644
--- a/anime.js
+++ b/anime.js
@@ -1007,9 +1007,14 @@
const params = mergeObjects(nextState, defaultState);
anime.remove(defaultState.targets);
const animation = anime(params);
+ animation.play();
if (bypassAnimation) animation.seek(animation.duration);
}
+ instance.switchTo = function(stateName) {
+ instance.goTo(stateName, true);
+ }
+
instance.finished = promise;
instance.reset();
diff --git a/documentation/examples/anime-states.html b/documentation/examples/anime-states.html
index f5662e24..15c604e5 100644
--- a/documentation/examples/anime-states.html
+++ b/documentation/examples/anime-states.html
@@ -44,8 +44,12 @@
var animation = anime({
targets: '.item',
+ translateX: 0,
+ translateY: 0,
+ scale: 1,
duration: 2000,
easing: 'easeOutExpo',
+ autoplay: false,
update: function() {
console.log('updating')
}