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

View in English Always switch to English

Animation.finished

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨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();
});

规范

Specification
Web Animations
# dom-animation-finished

浏览器兼容性

参见