Animation.reverse()

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

Document Tags and Contributors

 Contributors to this page: Sebastianz, teoli, jpmedley, kscarfone
 Last updated by: Sebastianz,