Skip to content

Commit f6e7b6c

Browse files
committed
Use this.running to know if we are still in process of showing/hidding a tab
1 parent 8b89feb commit f6e7b6c

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

ui/jquery.ui.tabs.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ $.widget( "ui.tabs", {
4444
var self = this,
4545
o = this.options;
4646

47+
this.running = false;
48+
4749
this.element.addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" );
4850

4951
this._processTabs();
@@ -294,9 +296,11 @@ $.widget( "ui.tabs", {
294296
$( clicked ).closest( "li" ).addClass( "ui-tabs-selected ui-state-active" );
295297

296298
if ( this.showFx ) {
299+
self.running = true;
297300
show.hide().removeClass( "ui-tabs-hide" ) // avoid flicker that way
298301
.animate( showFx, showFx.duration || "normal", function() {
299302
self._resetStyle( show, showFx );
303+
self.running = false;
300304
self._trigger( "show", event, self._ui( clicked, show[ 0 ] ) );
301305
});
302306
} else {
@@ -309,7 +313,9 @@ $.widget( "ui.tabs", {
309313
var self = this;
310314

311315
if ( this.hideFx ) {
316+
self.running = true;
312317
$hide.animate( hideFx, hideFx.duration || "normal", function() {
318+
self.running = false;
313319
self.lis.removeClass( "ui-tabs-selected ui-state-active" );
314320
$hide.addClass( "ui-tabs-hide" );
315321
self._resetStyle( $hide, hideFx );
@@ -346,14 +352,15 @@ $.widget( "ui.tabs", {
346352
$hide = self.panels.filter( ":not(.ui-tabs-hide)" ),
347353
$show = self.element.find( self._sanitizeSelector( el.hash ) );
348354

349-
// If tab is already selected and not collapsible or tab disabled or
350-
// or is already loading or click callback returns false stop here.
351-
// Check if click handler returns false last so that it is not executed
352-
// for a disabled or loading tab!
353-
if ( ( $li.hasClass( "ui-tabs-selected" ) && !o.collapsible) ||
355+
// tab is already selected, but not collapsible
356+
if ( ( $li.hasClass( "ui-tabs-selected" ) && !o.collapsible ) ||
357+
// can't switch durning an animation
358+
self.running ||
359+
// tab is disabled
354360
$li.hasClass( "ui-state-disabled" ) ||
361+
// tab is already loading
355362
$li.hasClass( "ui-state-processing" ) ||
356-
self.panels.filter( ":animated" ).length ||
363+
// allow canceling by select event
357364
self._trigger( "select", event, self._ui( el, $show[ 0 ] ) ) === false ) {
358365
el.blur();
359366
return;

0 commit comments

Comments
 (0)