You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
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);
}
};