Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. Animation
  4. cancel

Animation: cancel event

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2020.

Thecancel event of theAnimation interface is fired when theAnimation.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 acancel event on the new animation.

Syntax

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

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

Event type

AnAnimationPlaybackEvent. Inherits fromEvent.

Event AnimationPlaybackEvent

Event properties

In addition to the properties listed below, properties from the parent interface,Event, are available.

AnimationPlaybackEvent.currentTimeRead only

The current time of the animation that generated the event.

AnimationPlaybackEvent.timelineTimeRead only

The time value of the timeline of the animation that generated the event.

Examples

If this animation is canceled, remove its element.

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

Specifications

Specification
Web Animations
# dom-animation-oncancel
Web Animations
# cancel-event

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp