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 2020年3月.
Animation 接口的 Web 动画 API 的 cancel() 方法将清除此动画造成的所有 KeyframeEffect,并中止其播放。
备注:
当一个动画被取消时,其 startTime 和 currentTime 被设置为 null。
语法
js
cancel()
参数
无。
返回值
无。
异常
这个方法不会直接抛出异常; 但是,如果动画的 playState 取消时是除了“空闲”之外的任何东西,current finished promise 被拒绝与一个 DOMException 命名的AbortError.
规范
| Specification |
|---|
| Web Animations> # dom-animation-cancel> |
浏览器兼容性
Loading…
相关内容
- Web Animations API
KeyframeEffectAnimationAnimation.playStateAnimation.finishedreturns the promise this action will reject if the animation'splayStateis not"idle".