Animation: playState property

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.

The read-only Animation.playState property of the Web Animations API returns an enumerated value describing the playback state of an animation.

Value

idle

The current time of the animation is unresolved and there are no pending tasks.

running

The animation is running.

paused

The animation was suspended and the Animation.currentTime property is not updating.

finished

The animation has reached one of its boundaries and the Animation.currentTime property is not updating.

Previously, Web Animations defined a pending value to indicate that some asynchronous operation such as initiating playback was yet to complete. This is now indicated by the separate Animation.pending property.

Examples

In the Growing/Shrinking Alice Game example, players can get an ending with Alice crying into a pool of tears. In the game, for performance reasons, the tears should only be animating when they're visible. So they must be paused as soon as they are animated like so:

js
// Setting up the tear animations

tears.forEach((el) => {
  el.animate(tearsFalling, {
    delay: getRandomMsRange(-1000, 1000), // randomized for each tear
    duration: getRandomMsRange(2000, 6000), // randomized for each tear
    iterations: Infinity,
    easing: "cubic-bezier(0.6, 0.04, 0.98, 0.335)",
  });
  el.pause();
});

// Play the tears falling when the ending needs to be shown.

tears.forEach((el) => {
  el.play();
});

// Reset the crying tears animations and pause them.

tears.forEach((el) => {
  el.pause();
  el.currentTime = 0;
});

Specifications

Specification
Web Animations
# dom-animation-playstate

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
playState
Chrome – Full support
Chrome 75 (Release date: 2019-06-04)
footnote
footnote 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.
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 48 (Release date: 2016-08-02)
footnote
footnote Before 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.
Opera – Full support
Opera 62 (Release date: 2019-06-27)
footnote
footnote 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.
Safari – Full support
Safari 13.1 (Release date: 2020-03-24)
footnote Full support
Chrome Android – Full support
Chrome Android 75 (Release date: 2019-06-04)
footnote
footnote Before Chrome Android 50/Opera 37, this property returned idle for an animation that had not yet started. Starting with Chrome Android 50/Opera 37, it shows paused.
Firefox for Android – Full support
Firefox for Android 48 (Release date: 2016-08-02)
footnote
footnote Before Firefox for Android 59, this property returned pending for Animations with incomplete asynchronous operations but as of Firefox for Android 59 this is indicated by the separate Animation.pending property. This reflects recent changes to the specification.
Opera Android – Full support
Opera Android 54 (Release date: 2019-10-18)
footnote
footnote 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.
Safari on iOS – Full support
Safari on iOS 13.4 (Release date: 2020-03-24)
footnote Full support
Samsung Internet – Full support
Samsung Internet 11 (Release date: 2019-12-05)
footnote
footnote Before Samsung Internet 5.0/Opera 37, this property returned idle for an animation that had not yet started. Starting with Samsung Internet 5.0/Opera 37, it shows paused.
WebView Android – Full support
WebView Android 75 (Release date: 2019-06-04)
footnote
footnote Before WebView Android 50/Opera 37, this property returned idle for an animation that had not yet started. Starting with WebView Android 50/Opera 37, it shows paused.
WebView on iOS – Full support
WebView on iOS 13.4 (Release date: 2020-03-24)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

See also