We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

AnimationEffectTimingReadOnly.direction

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The 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.

Note: In AnimationEffectTiming, a mutable subclass of AnimationEffectTimingReadOnly used withKeyframeEffects, the property acts as both a getter and a setter.

Syntax

// Getting the direction of the animation
var animationPlaybackDirection = animation.effect.timing.direction;

// Setting the direction of the animation
animation.effect.timing.direction = reverse;

Value

A 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 "normal":

"normal"
The animation runs forwards, from beginning to end, in the way we experience the flow of time.
"reverse"
The animation runs backwards, or "rewinds."
"alternate"
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.
"alternate-reverse"
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.

Examples

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;

Specifications

Specification Status Comment
Web Animations
The definition of 'AnimationEffectTimingReadOnly.direction' in that specification.
Working Draft Editor's draft.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support Yes ?481 2 No Yes No
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung 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.

See also

Document Tags and Contributors

Contributors to this page: fscholz, rachelnabors, chrisdavidmills
Last updated by: fscholz,