Path: blob/main/files/en-us/web/api/animation/finish_event/index.md
6568 views
------{{ APIRef("Web Animations") }}
The finish event of the {{domxref("Animation")}} interface is fired when the animation finishes playing, either when the animation completes naturally, or when the {{domxref("Animation.finish()")}} method is called to immediately cause the animation to finish up.
Note: The
"paused"play state supersedes the"finished"play state; if the animation is both paused and finished, the"paused"state is the one that will be reported. You can force the animation into the"finished"state by setting its {{domxref("Animation.startTime", "startTime")}} todocument.timeline.currentTime - (Animation.currentTime * Animation.playbackRate).
Syntax
Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property.
Event type
An {{domxref("AnimationPlaybackEvent")}}. Inherits from {{domxref("Event")}}.
{{InheritanceDiagram("AnimationPlaybackEvent")}}
Event properties
In addition to the properties listed below, properties from the parent interface, {{domxref("Event")}}, are available.
{{domxref("AnimationPlaybackEvent.currentTime")}} {{ReadOnlyInline}}
: The current time of the animation that generated the event.
{{domxref("AnimationPlaybackEvent.timelineTime")}} {{ReadOnlyInline}}
: The time value of the timeline of the animation that generated the event.
Examples
Animation.onfinish is used several times in the Alice in Web Animations API Land Growing/Shrinking Alice Game. Here is one instance where we add pointer events back to an element after its opacity animation has faded it in:
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
{{domxref("Animation")}}
{{domxref("Animation.finish()")}}