This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.
The reverse() method of the Animation Interface moves the animation backwards, stopping at the start of the animation. If called on an unplayed animation, the whole animation is played backwards. If called on a paused animation, the animation will continue in reverse.
Syntax
element.reverse();
Example
The following example uses reverse() to toggle from an "after" image to a "before" image. This would be paired with similar code to do the opposite using play().
beforeButton = document.getElementById("before");
beforeButton.addEventListener('mousedown', function() {
player.reverse();
});
Specifications
| Specification | Status | Comment |
|---|---|---|
| Web Animations The definition of 'reverse()' in that specification. |
Working Draft |
Browser compatibility
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|
| Basic support | 39.0 | (Yes) [1] | ? | ? | ? |
| Feature | Android | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
|---|---|---|---|---|---|---|---|
| Basic support | ? | (Yes)[1] | ? | ? | ? | ? | ? |
[1] Before Firefox 40, this property was implemented on the AnimationPlayer interface.
See also
AnimationPlayerfor other methods and properties you can use to control web page animation.AnimationPlayer.pause()to pause an animation.AnimationPlayer.play()to move an animation forward.