web api instance method
Animation: cancel() method
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
startTimeandcurrentTimeare set tonull.
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 cancelled, the current finished promise is rejected with a DOMException named AbortError.
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.
See also
- Web Animations API
KeyframeEffectAnimationplayStatefinishedreturns the promise this action will reject if the animation’splayStateis not"idle".