Last active
December 16, 2015 12:18
-
-
Save ifthenelse/5433230 to your computer and use it in GitHub Desktop.
Use modernizr to check CSS transitions events support: * 'WebkitTransition':'webkitTransitionEnd' (Chrome / Safari)
* 'MozTransition':'transitionend' (Mozilla)
* 'OTransition':'oTransitionEnd' (Opera)
* 'transition':'transitionend' (Internet Explorer)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function whichTransitionEvent(){ | |
var t; | |
var el = document.createElement('fakeelement'); | |
var transitions = { | |
'transition':'transitionend', | |
'OTransition':'oTransitionEnd', | |
'MozTransition':'transitionend', | |
'WebkitTransition':'webkitTransitionEnd' | |
} | |
for(t in transitions){ | |
if( el.style[t] !== undefined ){ | |
return transitions[t]; | |
} | |
} | |
} | |
// To launch the event | |
var transitionEnd = whichTransitionEvent(); | |
element.addEventListener(transitionEnd, theFunctionToInvoke, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment