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 )
@@ -319,8 +319,6 @@ $.widget( "ui.accordion", {
319
319
event . preventDefault ( ) ;
320
320
321
321
if ( options . disabled ||
322
- // can't switch during an animation
323
- this . running ||
324
322
// click on active header, but not collapsible
325
323
( clickedIsActive && ! options . collapsible ) ||
326
324
// allow canceling activation
@@ -361,7 +359,6 @@ $.widget( "ui.accordion", {
361
359
toShow = data . newContent ,
362
360
toHide = data . oldContent ;
363
361
364
- self . running = true ;
365
362
function complete ( ) {
366
363
self . _completed ( data ) ;
367
364
}
@@ -382,6 +379,8 @@ $.widget( "ui.accordion", {
382
379
animations [ animation ] ( {
383
380
toShow : toShow ,
384
381
toHide : toHide ,
382
+ prevShow : lastToggle . toShow ,
383
+ prevHide : lastToggle . toHide ,
385
384
complete : complete ,
386
385
down : toShow . length && ( ! toHide . length || ( toShow . index ( ) < toHide . index ( ) ) )
387
386
} , additional ) ;
@@ -412,8 +411,6 @@ $.widget( "ui.accordion", {
412
411
var toShow = data . newContent ,
413
412
toHide = data . oldContent ;
414
413
415
- this . running = false ;
416
-
417
414
if ( this . options . heightStyle === "content" ) {
418
415
toShow . add ( toHide ) . css ( {
419
416
height : "" ,
@@ -435,6 +432,11 @@ $.widget( "ui.accordion", {
435
432
$ . extend ( $ . ui . accordion , {
436
433
animations : {
437
434
slide : function ( options , additions ) {
435
+ if ( options . prevShow || options . prevHide ) {
436
+ options . prevHide . stop ( true , true ) ;
437
+ options . toHide = options . prevShow ;
438
+ }
439
+
438
440
var showOverflow = options . toShow . css ( "overflow" ) ,
439
441
hideOverflow = options . toHide . css ( "overflow" ) ,
440
442
percentDone = 0 ,
@@ -446,6 +448,9 @@ $.extend( $.ui.accordion, {
446
448
easing : "swing" ,
447
449
duration : 300
448
450
} , options , additions ) ;
451
+
452
+ lastToggle = options ;
453
+
449
454
if ( ! options . toHide . size ( ) ) {
450
455
originalWidth = options . toShow [ 0 ] . style . width ;
451
456
options . toShow
@@ -502,10 +507,7 @@ $.extend( $.ui.accordion, {
502
507
. filter ( ":visible" )
503
508
. animate ( hideProps , {
504
509
step : function ( now , settings ) {
505
- // only calculate the percent when animating height
506
- // IE gets very inconsistent results when animating elements
507
- // with small values, which is common for padding
508
- if ( settings . prop == "height" ) {
510
+ if ( settings . prop == "height" || settings . prop == "paddingTop" || settings . prop == "paddingBottom" ) {
509
511
percentDone = ( settings . end - settings . start === 0 ) ? 0 :
510
512
( settings . now - settings . start ) / ( settings . end - settings . start ) ;
511
513
}
0 commit comments