Firefox Tomorrow

web api event

Animation: cancel event

View on MDN ↗

The cancel event of the Animation interface is fired when the cancel() method is called or 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

Use the event name in methods like addEventListener(), or set an event handler property.

addEventListener("cancel", (event) => { })

oncancel = (event) => { }

Event type

An AnimationPlaybackEvent. Inherits from Event.

Examples

If this animation is canceled, remove its element.

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

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also