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 isnull
.
Animation.effect
- Gets and sets the
AnimationEffectReadOnly
associated with this animation. This will usually be aKeyframeEffect
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.replaceState
- Returns the replace state of the animation. This will be
active
if the animation has been replaced, orpersisted
ifAnimation.persist()
has been invoked on it.
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. animation.onremove
- Allows you to set and run an event handler that fires when the animation is removed (i.e., put into an
active
replace state).
Methods
Animation.cancel()
- Clears all
keyframeEffects
caused by this animation and aborts its playback. animation.commitStyles()
- Commits the end styling state of an animation to the element being animated, even after that animation has been removed. It will cause the end styling state to be written to the element being animated, in the form of properties inside a
style
attribute.
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.persist()
- Explicitly persists an animation, when it would otherwise be removed due to the browser's Automatically removing filling animations behavior.
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.
Automatically removing filling animations
It is possible to trigger a large number of animations on the same element. If they are indefinite (i.e., forwards-filling), this can result in a huge animations list, which could create a memory leak. For this reason, modern browsers have implemented the part of the Web Animations spec that automatically removes overriding forward filling animations, unless the developer explicitly specifies to keep them.
You can see this in action in our simple [[../../../../../../mdn.github.io/dom-examples/web-animations-api/replace-indefinite-animations|replace indefinite animations demo]]. The related JavaScript features are:
animation.commitStyles()
for commiting the end styling state of an animation to the element being animated, even after that animation has been removed.animation.onremove
for setting and running an event handler that fires when the animation is removed (i.e., put into anactive
replace state).animation.persist()
for when you explicitly want an animations to be retained.animation.replaceState
to return the replace state of the animation. This will beactive
if the animation has been removed, orpersisted
ifpersist()
has been invoked.
Accessibility concerns
Blinking and flashing animation can be problematic for people with cognitive concerns such as Attention Deficit Hyperactivity Disorder (ADHD). Additionally, certain kinds of motion can be a trigger for Vestibular disorders, epilepsy, and migraine, and Scotopic sensitivity.
Consider providing a mechanism for pausing or disabling animation, as well as using the Reduced Motion Media Query to create a complimentary experience for users who have expressed a preference for no animated experiences.
- Designing Safer Web Animation For Motion Sensitivity · An A List Apart Article
- An Introduction to the Reduced Motion Media Query | CSS-Tricks
- Responsive Design for Motion | WebKit
- MDN Understanding WCAG, Guideline 2.2 explanations
- Understanding Success Criterion 2.2.2 | W3C Understanding WCAG 2.0
Specifications
Specification | Status | Comment |
Web AnimationsThe definition of 'Animation' in that specification. | Working Draft | Initial definition |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Chrome Full support 44 Full support 44 No support 39 — 44 Alternate Name' Uses the non-standard name: |
Edge
Full support 79 |
Firefox Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
IE
No support No |
Opera
Full support 26 |
Safari
Full support 13.1 |
WebView Android Full support 44 Full support 44 No support 39 — 44 Alternate Name' Uses the non-standard name: |
Chrome Android Full support 44 Full support 44 No support 39 — 44 Alternate Name' Uses the non-standard name: |
Firefox Android Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
Opera Android
Full support 26 |
Safari iOS
Full support 13.4 |
Samsung Internet Android
Full support 4.0 |
Chrome
Full support 61 |
Edge
Full support 79 |
Firefox Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
IE
No support No |
Opera
Full support 48 |
Safari
No support No |
WebView Android
Full support 61 |
Chrome Android
Full support 61 |
Firefox Android Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
Opera Android
Full support 45 |
Safari iOS
No support No |
Samsung Internet Android
Full support 8.0 | |
Chrome
Full support 39 |
Edge
Full support 79 |
Firefox Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
IE
No support No |
Opera
Full support 26 |
Safari
No support No |
WebView Android
Full support 39 |
Chrome Android
Full support 39 |
Firefox Android Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
Opera Android
Full support 26 |
Safari iOS
No support No |
Samsung Internet Android
Full support 4.0 | |
Chrome No support No No support No Notes' Currently Chrome Canary only |
Edge
No support No |
Firefox
Full support 75 |
IE
No support No |
Opera
No support No |
Safari
Full support 13.1 |
WebView Android
No support No |
Chrome Android No support No No support No Notes' Currently Chrome Canary only |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS Partial support 13.4 Partial support 13.4 Notes' Passes 13/27 web platform tests. |
Samsung Internet Android
No support No | |
Chrome
Full support 39 |
Edge
Full support 79 |
Firefox Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
IE
No support No |
Opera
Full support 26 |
Safari
No support No |
WebView Android
Full support 39 |
Chrome Android
Full support 39 |
Firefox Android Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
Opera Android
Full support 26 |
Safari iOS
No support No |
Samsung Internet Android
Full support 4.0 | |
Chrome
Full support 75 |
Edge
Full support 79 |
Firefox Full support 63 Full support 63 Full support 48 Notes' This property is supported in Firefox 48 but is read-only. It became writable in Firefox 51.
Disabled' From version 48: this feature is behind the |
IE
No support No |
Opera
Full support 62 |
Safari
No support No |
WebView Android
Full support 75 |
Chrome Android
Full support 75 |
Firefox Android Full support 63 Full support 63 Full support 48 Notes' This property is supported in Firefox 48 but is read-only. It became writable in Firefox 51.
Disabled' From version 48: this feature is behind the |
Opera Android
Full support 54 |
Safari iOS
No support No |
Samsung Internet Android
Full support 11.0 | |
Chrome
Full support 39 |
Edge
Full support 79 |
Firefox Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
IE
No support No |
Opera
Full support 26 |
Safari
No support No |
WebView Android
Full support 39 |
Chrome Android
Full support 39 |
Firefox Android Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
Opera Android
Full support 26 |
Safari iOS
No support No |
Samsung Internet Android
Full support 4.0 | |
Chrome
No support No |
Edge
No support No |
Firefox Full support 63 Full support 63 Full support 46 Disabled' From version 46: this feature is behind the |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android Full support 63 Full support 63 Full support 46 Disabled' From version 46: this feature is behind the |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No | |
Chrome
Full support 50 |
Edge
Full support 79 |
Firefox Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
IE
No support No |
Opera
Full support 37 |
Safari
No support No |
WebView Android
Full support 50 |
Chrome Android
Full support 50 |
Firefox Android Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
Opera Android
Full support 37 |
Safari iOS
No support No |
Samsung Internet Android
Full support 5.0 | |
Chrome
Full support 50 |
Edge
Full support 79 |
Firefox Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
IE
No support No |
Opera
Full support 37 |
Safari
No support No |
WebView Android
Full support 50 |
Chrome Android
Full support 50 |
Firefox Android Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
Opera Android
Full support 37 |
Safari iOS
No support No |
Samsung Internet Android
Full support 5.0 | |
Chrome
Full support 39 |
Edge
Full support 79 |
Firefox Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
IE
No support No |
Opera
Full support 26 |
Safari
No support No |
WebView Android
Full support 39 |
Chrome Android
Full support 39 |
Firefox Android Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
Opera Android
Full support 26 |
Safari iOS
No support No |
Samsung Internet Android
Full support 4.0 | |
Chrome No support No No support No Notes' Currently Chrome Canary only |
Edge
No support No |
Firefox
Full support 75 |
IE
No support No |
Opera
No support No |
Safari
Full support 13.1 |
WebView Android
No support No |
Chrome Android No support No No support No Notes' Currently Chrome Canary only |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
Full support 13.4 |
Samsung Internet Android
No support No | |
Chrome
Full support 39 |
Edge
Full support 79 |
Firefox Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
IE
No support No |
Opera
Full support 26 |
Safari
No support No |
WebView Android
Full support 39 |
Chrome Android
Full support 39 |
Firefox Android Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
Opera Android
Full support 26 |
Safari iOS
No support No |
Samsung Internet Android
Full support 4.0 | |
Chrome
No support No |
Edge
No support No |
Firefox Full support 59 Full support 59 Notes' Prior to version 59, the pending status was reported by a |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android Full support 59 Full support 59 Notes' Prior to version 59, the pending status was reported by a |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No | |
Chrome No support No No support No Notes' Currently Chrome Canary only |
Edge
No support No |
Firefox
Full support 75 |
IE
No support No |
Opera
No support No |
Safari
Full support 13.1 |
WebView Android
No support No |
Chrome Android No support No No support No Notes' Currently Chrome Canary only |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
Full support 13.4 |
Samsung Internet Android
No support No | |
Chrome
Full support 39 |
Edge
Full support 79 |
Firefox Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
IE
No support No |
Opera
Full support 26 |
Safari
No support No |
WebView Android
Full support 39 |
Chrome Android
Full support 39 |
Firefox Android Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
Opera Android
Full support 26 |
Safari iOS
No support No |
Samsung Internet Android
Full support 4.0 | |
Chrome
Full support 39 |
Edge
Full support 79 |
Firefox Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
IE
No support No |
Opera
Full support 26 |
Safari
No support No |
WebView Android
Full support 39 |
Chrome Android
Full support 39 |
Firefox Android Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
Opera Android
Full support 26 |
Safari iOS
No support No |
Samsung Internet Android
Full support 4.0 | |
Chrome Full support 39 Full support 39 Notes' Before Chrome 50/Opera 37, this property returned |
Edge
Full support 79 |
Firefox Full support 48 Full support 48 Notes' Prior to Firefox 59, this property returned Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
IE
No support No |
Opera Full support 26 Full support 26 Notes' Before Chrome 50/Opera 37, this property returned |
Safari
No support No |
WebView Android Full support 39 Full support 39 Notes' Before Chrome 50/Opera 37, this property returned |
Chrome Android Full support 39 Full support 39 Notes' Before Chrome 50/Opera 37, this property returned |
Firefox Android Full support 48 Full support 48 Notes' Prior to Firefox 59, this property returned Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
Opera Android Full support 26 Full support 26 Notes' Before Chrome 50/Opera 37, this property returned |
Safari iOS
No support No |
Samsung Internet Android Full support 4.0 Full support 4.0 Notes' Before Samsung Internet 5.0/Opera 37, this property returned | |
Chrome
No support No |
Edge
No support No |
Firefox Full support 63 Full support 63 Full support 46 Disabled' From version 46: this feature is behind the |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android Full support 63 Full support 63 Full support 46 Disabled' From version 46: this feature is behind the |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No | |
Browsers automatically remove indefinite filling animations. |
Chrome No support No No support No Notes' Currently Chrome Canary only |
Edge
No support No |
Firefox
Full support 75 |
IE
No support No |
Opera
No support No |
Safari
Full support 13.1 |
WebView Android
No support No |
Chrome Android No support No No support No Notes' Currently Chrome Canary only |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
Full support 13.4 |
Samsung Internet Android
No support No |
Chrome No support No No support No Notes' Currently Chrome Canary only |
Edge
No support No |
Firefox
Full support 75 |
IE
No support No |
Opera
No support No |
Safari
Full support 13.1 |
WebView Android
No support No |
Chrome Android No support No No support No Notes' Currently Chrome Canary only |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
Full support 13.4 |
Samsung Internet Android
No support No | |
Chrome
Full support 39 |
Edge
Full support 79 |
Firefox Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
IE
No support No |
Opera
Full support 26 |
Safari
No support No |
WebView Android
Full support 39 |
Chrome Android
Full support 39 |
Firefox Android Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
Opera Android
Full support 26 |
Safari iOS
No support No |
Samsung Internet Android
Full support 4.0 | |
Chrome
Full support 39 |
Edge
Full support 79 |
Firefox Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
IE
No support No |
Opera
Full support 26 |
Safari
No support No |
WebView Android
Full support 39 |
Chrome Android
Full support 39 |
Firefox Android Full support 48 Full support 48 No support 46 — 48 Disabled' From version 46 until version 48 (exclusive): this feature is behind the |
Opera Android
Full support 26 |
Safari iOS
No support No |
Samsung Internet Android
Full support 4.0 | |
Chrome No support No No support No Notes' Currently Chrome Canary only |
Edge
No support No |
Firefox Full support 75 Full support 75 Notes' Currently only the getter is supported Full support 63 Disabled' From version 63: this feature is behind the Notes' This property is supported in Firefox 48 but is read-only. It became writable in Firefox 49.
Disabled' From version 48 until version 63 (exclusive): this feature is behind the |
IE
No support No |
Opera
No support No |
Safari Full support 13.1 Full support 13.1 Notes' Currently only the getter is supported |
WebView Android
No support No |
Chrome Android No support No No support No Notes' Currently Chrome Canary only |
Firefox Android Full support 63 Full support 63 Disabled' From version 63: this feature is behind the Notes' This property is supported in Firefox 48 but is read-only. It became writable in Firefox 49.
Disabled' From version 48 until version 63 (exclusive): this feature is behind the |
Opera Android
No support No |
Safari iOS Full support 13.4 Full support 13.4 Notes' Currently only the getter is supported |
Samsung Internet Android
No support No | |
Chrome
No support No |
Edge
No support No |
Firefox
Full support 60 |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android
Full support 60 |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No |
Legend
- Full support
- Full support
- Partial support
- Partial support
- No support
- No support
- Experimental. Expect behavior to change in the future.'
- Experimental. Expect behavior to change in the future.
- See implementation notes.'
- See implementation notes.
- User must explicitly enable this feature.'
- User must explicitly enable this feature.
- Uses a non-standard name.'
- Uses a non-standard name.
See also
Animation by Mozilla Contributors is licensed under CC-BY-SA 2.5.