这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。
Animation 接口的 Web动画API的 cancel() 方法将清除此动画造成的所有KeyframeEffect ,并中止其播放。.
当一个动画被取消时,其 startTime 和currentTime 被设置为null。
语法
Animation.cancel();
参数
无.
返回值
无.
异常
这个方法不会直接抛出异常; 但是,如果动画的 playState 取消时是除了“空闲”之外的任何东西,current finished promise 被拒绝与一个 DOMException 命名的AbortError.
规范
| Specification | Status | Comment |
|---|---|---|
| Web Animations Animation.cancel() |
Working Draft | Editor's draft. |
浏览器兼容
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|
| Basic support | 39.0 | 48 (48)[1] | 未实现 | 未实现 | 未实现 |
| Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | (Yes) | 48.0 (48)[1] | 未实现 | 未实现 | 未实现 |
[1] The Web Animations API is only enabled by default in Firefox Developer Edition and Nightly builds. You can enable it in beta and release builds by setting the preference dom.animations-api.core.enabled to true, and can disable it in any Firefox version by setting this preference to false.
相关内容
- Web Animations API
KeyframeEffectAnimationAnimation.playStateAnimation.finishedreturns the promise this action will reject if the animation'splayStateis not"idle".