New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$.fn.animationComplete doesn't release callback when $.support.cssTransitions=true #5156

Closed
nonplus opened this Issue Oct 11, 2012 · 0 comments

Comments

Projects
None yet
1 participant
@nonplus

nonplus commented Oct 11, 2012

In v1.2.0 and earlier, $.fn.animationComplete(callback) leaks the supplied callback.

When $.support.cssTransitions is true in $.fn.animationComplete(), the function attaches the callback to both the webkitAnimationEnd and the animationend events.

However, only one of these will fire depending on the browser. For example, on WebkKit, the webkitAnimationEnd will fire but the callback will be retained on behalf of the animationend event which never fires. This leads to memory leaks.

The fix is to attach to a browser-specific event:

//animation complete callback
var animationEndEvent = "WebKitTransitionEvent" in window ? "webkitAnimationEnd" : "animationend";
$.fn.animationComplete = function(callback) {
    if ($.support.cssTransitions) {
        return $(this).one(animationEndEvent, callback);
    } else {
        // defer execution for consistency between webkit/non webkit
        setTimeout(callback, 0);
        return $(this);
    }
};

nonplus pushed a commit to nonplus/jquery-mobile that referenced this issue Oct 11, 2013

nonplus pushed a commit to nonplus/jquery-mobile that referenced this issue Oct 11, 2013

arschmitz added a commit that referenced this issue Jan 22, 2014

AnimationComplete: Add transition, fallbacks and remove memory leaks
Also no its own module including support tests for animations and
transitions

Fixes gh-5156
Fixes gh-6816
Fixes gh-6697
Fixes gh-6895
Fixes gh-6148

arschmitz added a commit that referenced this issue Feb 12, 2014

AnimationComplete: Add transition, fallbacks and remove memory leaks
Also no its own module including support tests for animations and
transitions

Fixes gh-5156
Fixes gh-6816
Fixes gh-6697
Fixes gh-6895
Fixes gh-6148
Closes gh-7001

@arschmitz arschmitz closed this in 749c78e Feb 12, 2014

idxbrokerAdmin added a commit to idxbroker/jquery-mobile that referenced this issue Jul 15, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment