I have multiple elements that are animating at a (somewhat) duration each. I'm animating using CSS3 transitions, using the jQuery library and a transitionend
helper function from David Walsh.
My issue is that the transitionEnd
event is NOT being fired! (In Chrome & Firefox)
My code:
var $children = $container.find('.slideblock').children();
if(Modernizr.csstransitions && Modernizr.csstransforms3d) {
if($.browser.webkit === true) {
$children.css('-webkit-transform-style','preserve-3d')
}
$children.each(function(i){
$(this).on(whichTransitionEvent,function () {
$(this).remove();
});
$(this).show().css('animation','slideOutToRight ' + ((Math.random() / 2) + .5) + 's');
});
}
Update
The whichTransitionEvent
variable points to a self-executing function that returns a string containing the event name:
var whichTransitionEvent = (function (){
var t;
var el = document.createElement('fakeelement');
var transitions = {
'transition' :'transitionEnd',
'OTransition' :'oTransitionEnd',
'MSTransition' :'msTransitionEnd',
'MozTransition' :'transitionend',
'WebkitTransition' :'webkitTransitionEnd'
}
for(t in transitions){
if( el.style[t] !== undefined ){
return transitions[t];
}
}
} ());
console.log(whichTransitionEvent); // returns "webkitTransitionEvent" in Chrome
console.log(typeof whichTransitionEvent); // returns "string"