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

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

Animation()
Creates a new Animation object instance.

Properties

Animation.currentTime
The current time value of the animation in milliseconds, whether running or paused. If the animation lacks a timeline, is inactive or hasn't been played yet, its value is null.
Animation.effect
Gets and sets the AnimationEffectReadOnly associated with this animation. This will usually be a KeyframeEffect object.
Animation.finished Read only
Returns the current finished Promise for this animation.
Animation.id
Gets and sets the String used to identify the animation.
Animation.pending Read only
Indicates whether the animation is currently waiting for an asynchronous operation such as initiating playback or pausing a running animation.
Animation.playState Read only
Returns an enumerated value describing the playback state of an animation.
Animation.playbackRate
Gets or sets the playback rate of the animation.
Animation.ready Read only
Returns the current ready Promise for this animation.
Animation.startTime
Gets or sets the scheduled time when an animation's playback should begin.
Animation.timeline
Gets or sets the timeline associated with this animation.

Event handlers

Animation.oncancel
Gets and sets the event handler for the cancel event.
Animation.onfinish
Gets and sets the event handler for the finish event.

Methods

Animation.cancel()
Clears all keyframeEffects caused by this animation and aborts its playback.
Animation.finish()
Seeks either end of an animation, depending on whether the animation is playing or reversing.
Animation.pause()
Suspends playing of an animation.
Animation.play()
Starts or resumes playing of an animation, or begins the animation again if it previously finished.
Animation.reverse()
Reverses playback direction, stopping at the start of the animation. If the animation is finished or unplayed, it will play from end to beginning.
Animation.updatePlaybackRate()
Sets the speed of an animation after first synchronizing its playback position.

Specifications

Specification Status Comment
Web Animations
The definition of 'Animation' in that specification.
Working Draft Initial definition

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support

44

39 — 441

?48 No26 No
Animation() constructor61 ?

48

46 — 482

No ? No
cancel39 ?

48

40 — 483

No26 No
currentTime39 ?

48

40 — 483

No26 No
effect No ?484 5 No No No
finish39 ?

48

40 — 483

No26 No
finished No ?406 No No No
id50 ?

48

46 — 482

No37 No
oncancel50 ?

48

42 — 487

No37 No
onfinish39 ?

48

42 — 487

No26 No
pause39 ?

48

36 — 488

No26 No
pending No ?599 No No No
play39 ?

48

36 — 488

No26 No
playbackRate39 ?

48

42 — 487

No26 No
playState3910 ?

4811

36 — 488

No2610 No
ready No ?3712 No No No
reverse39 ?

48

42 — 487

No26 No
startTime39 ?

48

39 — 4813

No26 No
timeline No ?4814 5 No No No
updatePlaybackRate No No60 No No No
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support

44

39 — 441

44

39 — 441

?4826 No4.0
Animation() constructor6161 ?

48

46 — 482

? No No
cancel3939 ?

48

40 — 483

26 No4.0
currentTime3939 ?

48

40 — 483

26 No4.0
effect No No ?484 5 No No No
finish3939 ?

48

40 — 483

26 No4.0
finished No No ?406 No No No
id5050 ?

48

46 — 482

37 No5.0
oncancel5050 ?

48

42 — 487

37 No5.0
onfinish3939 ?

48

42 — 487

26 No4.0
pause3939 ?

48

36 — 488

26 No4.0
pending No No ?599 No No No
play3939 ?

48

36 — 488

26 No4.0
playbackRate3939 ?

48

42 — 487

26 No4.0
playState39103910 ?

4811

36 — 488

2610 No4.0
ready No No ?3712 No No No
reverse3939 ?

48

42 — 487

26 No4.0
startTime3939 ?

48

39 — 4813

26 No4.0
timeline No No ?4814 5 No No No
updatePlaybackRate No No No60 No No No

1. Supported as AnimationPlayer.

2. From version 46 until version 48 (exclusive): this feature is behind the dom.animations-api.core.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

3. From version 40 until version 48 (exclusive): this feature is behind the dom.animations-api.core.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

4. This property is supported in Firefox 48 but is read-only. It became writable in Firefox 51.

5. From version 48: this feature is behind the dom.animations-api.core.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

6. From version 40: this feature is behind the dom.animations-api.core.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

7. From version 42 until version 48 (exclusive): this feature is behind the dom.animations-api.core.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

8. From version 36 until version 48 (exclusive): this feature is behind the dom.animations-api.core.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

9. Prior to version 59, the pending status was reported by a "pending" value returned from Animation.playState.

10. Before Chrome 50/Opera 37, this property returned idle for an animation that had not yet started. Starting with Chrome 50/Opera 37, it shows paused.

11. Prior to Firefox 59, this property returned pending for Animations with incomplete asynchronous operations but as of Firefox 59 this is indicated by the separate Animation.pending property. This reflects recent changes to the specification.

12. From version 37: this feature is behind the dom.animations-api.core.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

13. From version 39 until version 48 (exclusive): this feature is behind the dom.animations-api.core.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

14. This property is supported in Firefox 48 but is read-only. It became writable in Firefox 49.

Document Tags and Contributors

 Last updated by: chrisdavidmills,