Animation.oncancel
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.
Web Animations API 的 Animation
接口的 oncancel
属性是 cancel
事件的事件处理程序。
当动作从其他状态进入 "idle"
播放状态,例如当动画在结束播放后从元素中移除时,cancel
事件可以 Animation.cancel()
被手动触发。
备注:
在新的动画中,创建一个新的初始的空闲动画不会触发 cancel
事件。
语法
js
addEventListener("cancel", (event) => { })
oncancel = (event) => { }
值
当动画被取消时,这个函数将会被执行。默认是 null
。
例子
如果动画被取消,将会从元素中移除它。
js
animation.oncancel = animation.effect.target.remove();
标准
Specification |
---|
Web Animations # dom-animation-oncancel |
Web Animations # cancel-event |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
cancel event |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.