12
12
* jquery.ui.widget.js
13
13
*/
14
14
( function ( $ , undefined ) {
15
+
16
+ var lastToggle = { } ;
15
17
16
18
// TODO: use ui-accordion-header-active class and fix styling
17
19
$ . widget ( "ui.accordion" , {
@@ -37,8 +39,6 @@ $.widget( "ui.accordion", {
37
39
var self = this ,
38
40
options = self . options ;
39
41
40
- self . running = false ;
41
-
42
42
self . element . addClass ( "ui-accordion ui-widget ui-helper-reset" ) ;
43
43
44
44
self . headers = self . element . find ( options . header )
@@ -321,8 +321,6 @@ $.widget( "ui.accordion", {
321
321
event . preventDefault ( ) ;
322
322
323
323
if ( options . disabled ||
324
- // can't switch during an animation
325
- this . running ||
326
324
// click on active header, but not collapsible
327
325
( clickedIsActive && ! options . collapsible ) ||
328
326
// allow canceling activation
@@ -363,7 +361,6 @@ $.widget( "ui.accordion", {
363
361
toShow = data . newContent ,
364
362
toHide = data . oldContent ;
365
363
366
- self . running = true ;
367
364
function complete ( ) {
368
365
self . _completed ( data ) ;
369
366
}
@@ -384,6 +381,8 @@ $.widget( "ui.accordion", {
384
381
animations [ animation ] ( {
385
382
toShow : toShow ,
386
383
toHide : toHide ,
384
+ prevShow : lastToggle . toShow ,
385
+ prevHide : lastToggle . toHide ,
387
386
complete : complete ,
388
387
down : toShow . length && ( ! toHide . length || ( toShow . index ( ) < toHide . index ( ) ) )
389
388
} , additional ) ;
@@ -414,8 +413,6 @@ $.widget( "ui.accordion", {
414
413
var toShow = data . newContent ,
415
414
toHide = data . oldContent ;
416
415
417
- this . running = false ;
418
-
419
416
if ( this . options . heightStyle === "content" ) {
420
417
toShow . add ( toHide ) . css ( {
421
418
height : "" ,
@@ -437,6 +434,11 @@ $.widget( "ui.accordion", {
437
434
$ . extend ( $ . ui . accordion , {
438
435
animations : {
439
436
slide : function ( options , additions ) {
437
+ if ( options . prevShow || options . prevHide ) {
438
+ options . prevHide . stop ( true , true ) ;
439
+ options . toHide = options . prevShow ;
440
+ }
441
+
440
442
var showOverflow = options . toShow . css ( "overflow" ) ,
441
443
hideOverflow = options . toHide . css ( "overflow" ) ,
442
444
percentDone = 0 ,
@@ -448,6 +450,9 @@ $.extend( $.ui.accordion, {
448
450
easing : "swing" ,
449
451
duration : 300
450
452
} , options , additions ) ;
453
+
454
+ lastToggle = options ;
455
+
451
456
if ( ! options . toHide . size ( ) ) {
452
457
originalWidth = options . toShow [ 0 ] . style . width ;
453
458
options . toShow
@@ -504,10 +509,7 @@ $.extend( $.ui.accordion, {
504
509
. filter ( ":visible" )
505
510
. animate ( hideProps , {
506
511
step : function ( now , settings ) {
507
- // only calculate the percent when animating height
508
- // IE gets very inconsistent results when animating elements
509
- // with small values, which is common for padding
510
- if ( settings . prop == "height" ) {
512
+ if ( settings . prop == "height" || settings . prop == "paddingTop" || settings . prop == "paddingBottom" ) {
511
513
percentDone = ( settings . end - settings . start === 0 ) ? 0 :
512
514
( settings . now - settings . start ) / ( settings . end - settings . start ) ;
513
515
}
0 commit comments