Animation.cancel()

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.

We'd love to hear more about your role and the company you work for
Please help us by answering a few questions.

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

Animation 接口的 Web 动画 API 的 cancel() 方法将清除此动画造成的所有 KeyframeEffect,并中止其播放。

备注: 当一个动画被取消时,其 startTimecurrentTime 被设置为 null。

语法

js
cancel()

参数

无。

返回值

无。

异常

这个方法不会直接抛出异常; 但是,如果动画的 playState 取消时是除了“空闲”之外的任何东西,current finished promise 被拒绝与一个 DOMException 命名的AbortError.

规范

Specification
Web Animations
# dom-animation-cancel

浏览器兼容性

相关内容