Animation.cancel()
Experimental: 这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。
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)Animation
Animation.playState
Animation.finished
returns the promise this action will reject if the animation'splayState
is not"idle"
.