This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage 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 specification changes.
The finish()
method of the Animation
Interface seeks either end of an animation, depending on whether the animation is playing or reversing.
Syntax
element.finish();
Errors
An InvalidState
error is raised if the player's playback rate is 0 or the player's playback rate is greater than 0 and the end time of the animation is infinity.
The following example shows how to use the finish()
method and catch an InvalidState
error.
interfaceElement.addEventListener("mousedown", function() { try { player.finish(); } catch(e if e instanceof InvalidState) { console.log("finish() called on paused or finished animation."); } catch(e); logMyErrors(e); //pass exception object to error handler } });
Specifications
Specification | Status | Comment |
---|---|---|
Web Animations The definition of 'finish()' in that specification. |
Working Draft |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 39.0 | (Yes) [1] | ? | ? | ? |
Feature | Android | Andorid Webview | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | ? | ? | (Yes) [1] | ? | ? | ? | ? | 39.0 |
[1] Before Firefox 40, this property was implemented on the AnimationPlayer
interface.
See also
AnimationPlayer
for other methods and properties you can use to control web page animation.AnimationPlayer.play()
to move an animation forward.AnimationPlayer.reverse()
to move an animation backward.