The Web Animations API's cancel() method of the Animation interface clears all KeyframeEffects caused by this animation and aborts its playback.
Note: When an animation is cancelled, its startTime and currentTime are set to null.
The Web Animations API's cancel() method of the Animation interface clears all KeyframeEffects caused by this animation and aborts its playback.
Note: When an animation is cancelled, its startTime and currentTime are set to null.
js
cancel()
None.
None (undefined).
This method doesn't directly throw exceptions; however, if the animation's playState is anything but "idle" when cancelled, the current finished promise is rejected with a DOMException named AbortError.
| Specification |
|---|
| Web Animations # dom-animation-cancel |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
cancel |
75 | 79 | 48 | No | 62 | 13.1 | 75 | 75 | 48 | 54 | 13.4 | 11.0 |
KeyframeEffectAnimationAnimation.playStateAnimation.finished returns the promise this action will reject if the animation's playState is not "idle".© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Animation/cancel