Document: transitionend event - Web APIs 编辑
The transitionend
event is fired when a CSS transition has completed. In the case where a transition is removed before completion, such as if the transition-property
is removed or display
is set to none
, then the event will not be generated.
Bubbles | Yes |
---|---|
Cancelable | Yes |
Interface | TransitionEvent |
Event handler property | ontransitionend |
The transitionend
event is fired in both directions - as it finishes transitioning to the transitioned state, and when it fully reverts to the default or non-transitioned state. If there is no transition delay or duration, if both are 0s or neither is declared, there is no transition, and none of the transition events are fired. If the transitioncancel
event is fired, the transitionend
event will not fire.
The original target for this event is the Element
that had the transition applied. You can listen for this event on the Document
interface to handle it in the capture or bubbling phases. For full details on this event please see the page on HTMLElement: transitionend.
Examples
This code adds a listener to the transitionend
event:
document.addEventListener('transitionend', () => {
console.log('Transition ended');
});
The same, but using the ontransitionend
property instead of addEventListener()
:
document.ontransitionend = () => {
console.log('Transition ended');
};
See a live example of this event.
Specifications
Specification | Status | Comment |
---|---|---|
CSS Transitions The definition of 'transitionend' in that specification. | Working Draft | Initial definition. |
Browser compatibility
BCD tables only load in the browser
See also
- The
GlobalEventHandlers.ontransitionend
event handler - The
TransitionEvent
interface - CSS properties:
transition
,transition-delay
,transition-duration
,transition-property
,transition-timing-function
- Related events:
transitionrun
,transitionstart
,transitioncancel
- This event on
HTMLElement
targets:transitionend
- This event on
Window
targets:transitionend
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论