Skip to content

Commit 8ac4636

Browse files
committed
fix for multiple clicks when animating horizontal tabs
1 parent 3153487 commit 8ac4636

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/tabs/tabs.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,31 @@
9090
* @deprecated will be replaced with a more robust implementation
9191
*/
9292

93-
var w;
93+
var
94+
/**
95+
* @type {Boolean}
96+
*
97+
* Mutex to control horizontal animation
98+
* Disables clicking of tabs while animating
99+
* They mess up otherwise as currentPane gets set *after* animation is done
100+
*/
101+
animating,
102+
/**
103+
* @type {Number}
104+
*
105+
* Initial width of tab panes
106+
*/
107+
w;
94108

95109
$.tools.tabs.addEffect("horizontal", function(i, done) {
110+
if (animating) return; // don't allow other animations
96111

97112
var nextPane = this.getPanes().eq(i),
98113
currentPane = this.getCurrentPane();
99114

100115
// store original width of a pane into memory
101116
w || ( w = this.getPanes().eq(0).width() );
117+
animating = true;
102118

103119
nextPane.show(); // hidden by default
104120

@@ -111,11 +127,15 @@
111127
complete: function(){
112128
$(this).hide();
113129
done.call();
130+
animating = false;
114131
}
115132
});
116133
// Dirty hack... onLoad, currentPant will be empty and nextPane will be the first pane
117-
// If this is the case, manually run callback since the animation never occured
118-
if (!currentPane.length){ done.call(); }
134+
// If this is the case, manually run callback since the animation never occured, and reset animating
135+
if (!currentPane.length){
136+
done.call();
137+
animating = false;
138+
}
119139
});
120140

121141

0 commit comments

Comments
 (0)