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