« Back to Index

Firefox chokes on this code without the setTimeout

View original Gist on GitHub

firefox-bug.js

/*
    This is ugly.
    Firefox doesn't trigger a transitionend event unless the ui is unblocked.
    So I use a timeout to cause the ui thread to become unblocked allowing the event code to work.
 */
window.setTimeout(function(){
    element.on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){
        element.remove();
    });

    if (!featureDetector.can('CssTransition')) {
        element.remove();
    }

    element.addClass('setOpacityToZero');
}, 0);