Animation.finished

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

Animation.finished 只读属性允许您返回动画的完成状态。

备注: The Promise is replaced with a new (pending) Promise object every time the animation leaves the finished play state.

语法

js

var animationsPromise = animation.finished;

一个 Promise 对象。

例子

以下代码会等到所有动画都完成,然后再移除它们处于活动状态的元素:

js

Promise.all(
  elem.getAnimations().map(
    function(animation) {
      return animation.finished
    }
  )
).then(
  function() {
    return elem.remove();
  }
);

规范

Specification
Web Animations
# dom-animation-finished

浏览器兼容性

BCD tables only load in the browser

参见