I'm trying to create a css animation callback. I think the only way to do it is with JavaScript. I'm going to have to normalize the callback name to have it cross browser support. I came upon this answer, which has the following code (a bit edited):
function transitionEndEventName () {
var undefined,
transitions = {
'transition':'transitionend',
'OTransition':'otransitionend', // oTransitionEnd in very old Opera
'MozTransition':'transitionend',
'WebkitTransition':'webkitTransitionEnd'
};
for (var i in transitions) {
if (transitions.hasOwnProperty(i) && document.documentElement.style[i] !== undefined) {
return transitions[i];
}
}
return false
}
var transitionEnd = transitionEndEventName();
if (transitionEnd) {
element.addEventListener(transitionEnd, theFunctionToInvoke);
}
My question is, is this still valid now, (Jan 2016)? Also, is it necessary to add an else
statement (If transitionEnd === false) then add a timer, or will it never equal false?