Animation: cancel() method
Web Animations
Web Animations
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 canceled, its startTime and currentTime are set to
null.
Syntax
cancel()
Parameters
None.
Return value
None (undefined).
Exceptions
This method doesn't directly throw exceptions; however, if the animation's playState is anything but "idle" when canceled, the current finished promise is rejected with a DOMException named AbortError.
Specifications
Browser compatibility
See also
- Web Animations API
- KeyframeEffect
- Animation
- Animation.playState
- Animation.finished returns the promise this action will reject if the animation's
playStateis not"idle".