Are there any events fired by an element to check wether a css3 transition has started or end?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
Just for fun, don't do this!
I was using the approach given by Pete, however I have now started using the following
Alternatively if you use bootstrap then you can simply do
This is becuase they include the following in bootstrap.js
Note they also include an emulateTransitionEnd function which may be needed to ensure a callback always occurs.
http://blog.alexmaccaw.com/css-transitions
If you simply want to detect only a single transition end, without using any JS framework here's a little convenient utility function:
Usage:
then if you wish to cancel at some point you can still do it with
It's good for other event usages as well :)
W3C CSS Transitions Draft
Webkit
Mozilla
Opera
Internet Explorer
SO: How do I normalize CSS3 Transition functions across browsers?
In Opera 12 when you bind using the plain JavaScript, 'oTransitionEnd' will work:
however if you bind through jQuery, you need to use 'otransitionend'
In case you are using Modernizr or bootstrap-transition.js you can simply do a change:
You can find some info here as well http://www.ianlunn.co.uk/blog/articles/opera-12-otransitionend-bugs-and-workarounds/
All modern browsers now support the unprefixed event:
element.addEventListener('transitionend', callback, false);
Works in the latest versions of Chrome, Firefox and Safari. Even IE10+.