Skip to content

armgit / anime

Public Imported from GitHub
0

JavaScript animation engine

Improve states documentation examples

Julian Garnierb1521d315160
diff --git a/documentation/examples/anime-speed-test.html b/documentation/examples/anime-speed-test.html
index 9f27530b..62a4a775 100644
--- a/documentation/examples/anime-speed-test.html
+++ b/documentation/examples/anime-speed-test.html
@@ -61,14 +61,14 @@
var el = document.createElement('div');
el.classList.add('particule');
el.style.backgroundColor = 'hsl(' + hue + ', 100%, 50%)';
- el.style.transform = 'rotate(' + i * 1 + 'deg) translateX(1000vw)';
+ el.style.transform = 'rotate(' + i * 1 + 'deg) translateX(100px)';
document.body.appendChild(el);
anime({
targets: el,
//rotate: '+=2turn',
- translateX: '10vw',
+ translateX: '1rem',
// scaleY: [
// {value: [1, .1]},
// {value: 1}
@@ -82,7 +82,7 @@
// {value: anime.getValue(el, 'height', 'px')}
// ],
easing: 'linear',
- //direction: 'alternate',
+ direction: 'alternate',
duration: duration,
loop: true
});
diff --git a/documentation/index.html b/documentation/index.html
index e2fdb4c0..535ea74f 100644
--- a/documentation/index.html
+++ b/documentation/index.html
@@ -2029,24 +2029,43 @@ animation.states.stateName = {
<div class="large square shadow"></div>
<div class="large square el"></div>
</div>
+ <div class="line player align-items">
+ <button class="state-a-button">Animate to A</button>
+ <button class="state-b-button">Animate to B</button>
+ </div>
</div>
<script>var statesInitialisation = function() {
/*DEMO*/
var animation = anime({
targets: '.states-demo .el',
- easing: 'easeInOutCirc' // defin default easing applied to all states
+ duration: 2000,
+ easing: 'easeInOutCirc' // define default easing applied to all states
});
-animation.states.alignedRight = { translateX: 250 };
-animation.states.alignedLeft = { translateX: 0 };
+animation.states.stateA = {
+ translateX: 0,
+ borderRadius: '0%'
+}
-// Go to state A instantly
-animation.goTo('alignedRight');
+animation.states.stateB = {
+ translateX: 250,
+ borderRadius: '50%'
+}
-// Animate to state B with a duration of 2000
-animation.animateTo('alignedLeft', {
- duration: 2000
-});
+// Go to state B instantly
+animation.goTo('stateB');
+
+document.body.querySelector('.states-demo .state-a-button').onclick = function() {
+ // Animate to state A with default parameters
+ animation.animateTo('stateA');
+}
+
+document.body.querySelector('.states-demo .state-b-button').onclick = function() {
+ // Animate to state B with custom easing parameter
+ animation.animateTo('stateB', {
+ easing: 'easeOutExpo'
+ });
+}
/*DEMO*/
}