Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 01133b7

Browse files
author
Gabriel Schulhof
committed
animationComplete: Remove only the handler attached by us
Fixes gh-7265
1 parent 6e9db49 commit 01133b7

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

js/animationComplete.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ define( [
4949
$.fn.animationComplete = function( callback, type, fallbackTime ) {
5050
var timer, duration,
5151
that = this,
52+
eventBinding = function() {
53+
54+
// Clear the timer so we don't call callback twice
55+
clearTimeout( timer );
56+
callback.apply( this, arguments );
57+
},
5258
animationType = ( !type || type === "animation" ) ? "animation" : "transition";
5359

5460
// Make sure selected type is supported by browser
@@ -76,17 +82,12 @@ define( [
7682

7783
// Sets up the fallback if event never comes
7884
timer = setTimeout( function() {
79-
$( that ).off( props[ animationType ].event );
85+
$( that ).off( props[ animationType ].event, eventBinding );
8086
callback.apply( that );
8187
}, duration );
8288

8389
// Bind the event
84-
return $( this ).one( props[ animationType ].event, function() {
85-
86-
// Clear the timer so we dont call callback twice
87-
clearTimeout( timer );
88-
callback.call( this, arguments );
89-
});
90+
return $( this ).one( props[ animationType ].event, eventBinding );
9091
} else {
9192

9293
// CSS animation / transitions not supported

0 commit comments

Comments
 (0)