这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

动画 .playState 特性为 Web 动画 API returns and sets an enumerated value describing the playback state of an animation.

This property is read-only for CSS Animations and Transitions.

句法

var currentPlayState = Animation.playState;
Animation.playState = newState;
					

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 特性。

范例

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:

// Setting up the tear animations
tears.forEach(function(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(function(el) {
  el.play();
});
// Reset the crying tears animations and pause them.
tears.forEach(function(el) {
  el.pause();
  el.currentTime = 0;
});
					

规范

规范 状态 注释
Web 动画
The definition of 'playState' in that specification.
工作草案 初始定义。

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
playState Chrome 39 注意事项
39 注意事项
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 ≤79 Firefox 48 注意事项
48 注意事项
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.
46 — 48 Disabled
Disabled ). To change preferences in Firefox, visit
IE 不支持 No Opera 26 注意事项
26 注意事项
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 不支持 No WebView Android 39 注意事项
39 注意事项
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 .
Chrome Android 39 注意事项
39 注意事项
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 .
Firefox Android 48 注意事项
48 注意事项
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.
46 — 48 Disabled
Disabled ). To change preferences in Firefox, visit
Opera Android 26 注意事项
26 注意事项
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 iOS 不支持 No Samsung Internet Android 4.0 注意事项
4.0 注意事项
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 .

图例

完整支持

完整支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

见实现注意事项。

用户必须明确启用此特征。

用户必须明确启用此特征。

另请参阅

元数据

  • 最后修改: