{{ SeeCompatTable() }}{{ APIRef("Web Animations API") }}
The Animation.oncancel
property of the Web Animations API is the event handler for the cancel
event.
The cancel
event can be triggered manually with {{domxref("Animation.cancel()")}} or at an instance when the animation enters an idle play state from another state. (For instance, removing an animation before it has the chance to enter the finish
play state.)
Note: Creating a new animation that is initially idle does not generate a new cancel event.
Syntax
// getting oncancel var uponCancellation = animation.oncancel; // setting oncancel animation.oncancel = cancelAction;
Value
A function to be executed when the animation is cancelled or null.
Examples
If this animation is canceled, remove its element.
animation.oncancel = animation.effect.target.remove();
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('Web Animations', '#dom-animation-oncancel', 'Animation.oncancel' )}} | {{Spec2('Web Animations')}} | Editor's draft. |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | {{CompatUnknown}} | {{CompatGeckoDesktop(40)}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Feature | Android | Android Webview | Chrome for Android | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|---|
Basic support | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{ CompatUnknown}} | {{CompatUnknown}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
See also
- Web Animations API
- {{domxref("Animation")}}