{{ APIRef("Web Animations API") }}{{SeeCompatTable}}
The Animation
interface of the Web Animations API represents a single animation player and provides playback controls and a timeline for an animation node or source.
Constructor
- {{domxref("Animation.Animation()", "Animation()")}}
- Creates a new
Animation
object instance.
Properties
- {{domxref("Animation.currentTime")}}
- The current time value of the animation in milliseconds, whether running or paused. If the animation lacks a {{domxref("AnimationTimeline", "timeline")}}, is inactive or hasn't been played yet, its value is
null
.
- {{domxref("Animation.effect")}}
- Gets and sets the {{domxref("KeyframeEffect")}} associated with this animation.
- {{domxref("Animation.finished")}} {{readOnlyInline}}
- Returns the current finished Promise for this animation.
- {{domxref("Animation.id")}}
- Gets and sets the
String
used to identify the animation. - {{domxref("Animation.oncancel")}}
- Gets and sets the event handler for the
cancel
event. - {{domxref("Animation.onfinish")}}
- Gets and sets the event handler for the
finish
event. - {{domxref("Animation.playState")}} {{readOnlyInline}}
- Returns an enumerated value describing the playback state of an animation.
- {{domxref("Animation.playbackRate")}}
- Gets or sets the playback rate of the animation.
- {{domxref("Animation.ready")}} {{readOnlyInline}}
- Returns the current ready Promise for this animation.
- {{domxref("Animation.startTime")}}
- Gets or sets the scheduled time when an animation's playback should begin.
- {{domxref("Animation.timeline")}}
- Gets or sets the {{domxref("AnimationTimeline", "timeline")}} associated with this animation.
Methods
- {{domxref("Animation.cancel()")}}
- Clears all {{domxref("KeyframeEffect", "keyframeEffects")}} caused by this animation and aborts its playback.
- {{domxref("Animation.finish()")}}
- Seeks either end of an animation, depending on whether the animation is playing or reversing.
- {{domxref("Animation.pause()")}}
- Suspends playing of an animation.
- {{domxref("Animation.play()")}}
- Starts or resumes playing of an animation, or begins the animation again if it previously finished.
- {{domxref("Animation.reverse()")}}
- Moves the animation backwards, stopping at the start of the animation.
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName("Web Animations", "#the-animation-interface", "Animation")}} | {{Spec2("Web Animations")}} | Initial definition |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | {{CompatChrome(39.0)}} [1] | {{CompatGeckoDesktop(40.0)}} [2] | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} [1] | {{CompatGeckoDesktop(40.0)}} [2] | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
[1] Implemented as AnimationPlayer
(interface name in an early version of the spec).
[2] Before Firefox 40, it was available as AnimationPlayer
. In both cases, you need to set the preference dom.animations-api.core.enabled
to be able to use it.