Animation.oncancel

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The oncancel property of the Web Animations API's Animation interface is the event handler for the cancel event.

The cancel event can be triggered manually with Animation.cancel() when the animation enters the "idle" play state from another state, such as when the animation is removed from an element before it finishes playing

Note: Creating a new animation that is initially idle does not trigger a cancel event on the new animation.

Syntax

var cancelHandler = Animation.oncancel;

Animation.oncancel = cancelHandler;

Value

A function to be executed when the animation is cancelled, or null if there is no cancel event handler.

Examples

If this animation is canceled, remove its element.

animation.oncancel = function() { animation.effect.target.remove(); };

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
oncancel
50
79
48
No
37
13.1
50
50
48
37
13.4
5.0

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Animation/oncancel