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 March 2020.

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

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

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
finished

Legend

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

Full support
Full support

参见