direction property of the
AnimationEffectTimingReadOnly dictionary object represents the direction of the animation's playback along its timeline and its behavior after completing each iteration.
// Getting the direction of the animation var animationPlaybackDirection = animation.effect.timing.direction; // Setting the direction of the animation animation.effect.timing.direction = reverse;
DOMString which specifies the direction in which the animation should play as well as what to do when the playback reaches the end of the animation sequence in the current direction. It can take one of the following values, with the default being
- The animation runs forwards, from beginning to end, in the way we experience the flow of time.
- The animation runs backwards, or "rewinds."
- The animation switches direction after each iteration, going forward through the animation sequence the first iteration, then backward through the sequence the second iteration, and so forth.
- Similar to "alternate", except the animation playback starts by going from the end of the animation sequence toward the beginning the first iteration, then goes forward during the second, and so forth.
In the Red Queen's Race example, we can inspect the Red Queen and Alice's animation to discover a production secret:
// Returns "reverse" because the sprite was created upside down! return redQueen_alice.effect.timing.direction;
The definition of 'AnimationEffectTimingReadOnly.direction' in that specification.
|Working Draft||Editor's draft.|
|Feature||Android webview||Chrome for Android||Edge mobile||Firefox for Android||Opera Android||iOS Safari||Samsung Internet|
|Basic support||?||?||?||481 2||No||No||?|
1. The preference is set to
true by default on Firefox Nightly and on Firefox Developer Edition, but not on the official release.
2. From version 48: this feature is behind the
dom.animations-api.core-enabled preference (needs to be set to
true). To change preferences in Firefox, visit about:config.