Experimental
This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The Web Animations API's cancel()
method of the Animation
interface clears all KeyframeEffect
s caused by this animation and aborts its playback.
When an animation is cancelled, its startTime
and currentTime
are set to null
.
Syntax
Animation.cancel();
Parameters
None.
Return value
None.
Exceptions
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
.
Specifications
Specification | Status | Comment |
---|---|---|
Web Animations The definition of 'Animation.cancel()' in that specification. |
Working Draft | Editor's draft. |
Browser compatibility
BCD tables only load in the browser
See also
- Web Animations API
KeyframeEffect
Animation
Animation.playState
Animation.finished
returns the promise this action will reject if the animation'splayState
is not"idle"
.