Skip to content

Instantly share code, notes, and snippets.

@radist2s
Last active October 25, 2017 14:21
Show Gist options
  • Save radist2s/7ac240782ab847bea202 to your computer and use it in GitHub Desktop.
Save radist2s/7ac240782ab847bea202 to your computer and use it in GitHub Desktop.
Get transition complete event name
var transitionEventName
function getTransitionEndEventName() {
if (transitionEventName !== undefined) {
return transitionEventName
}
var detectedTransition,
el = document.createElement('transitiondetector'),
transitions = {
'transition': 'transitionend',
// see also http://ianlunn.co.uk/articles/opera-12-otransitionend-bugs-and-workarounds/
'OTransition': 'oTransitionEnd',
'MozTransition': 'transitionend',
'webkitTransition': 'webkitTransitionEnd'
}
Object.keys(transitions).some(function (transition) {
if (el.style[transition] !== undefined) {
detectedTransition = transitions[transition]
return true
}
return false
})
if (!detectedTransition) {
detectedTransition = false
}
return (transitionEventName = detectedTransition)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment