此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Animation.finished

基线 广泛可用

自 2020年7月 起,此特性已在主流浏览器中得到支持,可在大多数设备和浏览器版本中正常使用。

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

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();
});

规范

规范
Web Animations
# dom-animation-finished

浏览器兼容性

参见