@@ -21,7 +21,7 @@ angular.module('ui.bootstrap.collapse',['ui.bootstrap.transition'])
21
21
link : function ( scope , element , attrs ) {
22
22
23
23
var isCollapsed ;
24
-
24
+ var initialAnimSkip = true ;
25
25
scope . $watch ( function ( ) { return element [ 0 ] . scrollHeight ; } , function ( value ) {
26
26
//The listener is called when scollHeight changes
27
27
//It actually does on 2 scenarios:
@@ -30,7 +30,7 @@ angular.module('ui.bootstrap.collapse',['ui.bootstrap.transition'])
30
30
//When we have a change of scrollHeight we are setting again the correct height if the group is opened
31
31
if ( element [ 0 ] . scrollHeight !== 0 ) {
32
32
if ( ! isCollapsed ) {
33
- doTransition ( { height : element [ 0 ] . scrollHeight + 'px' } ) ;
33
+ fixUpHeight ( scope , element , element [ 0 ] . scrollHeight + 'px' ) ;
34
34
}
35
35
}
36
36
} ) ;
@@ -58,21 +58,33 @@ angular.module('ui.bootstrap.collapse',['ui.bootstrap.transition'])
58
58
} ;
59
59
60
60
var expand = function ( ) {
61
- doTransition ( { height : element [ 0 ] . scrollHeight + 'px' } )
62
- . then ( function ( ) {
63
- // This check ensures that we don't accidentally update the height if the user has closed
64
- // the group while the animation was still running
61
+ if ( initialAnimSkip ) {
62
+ initialAnimSkip = false ;
65
63
if ( ! isCollapsed ) {
66
64
fixUpHeight ( scope , element , 'auto' ) ;
67
65
}
68
- } ) ;
66
+ } else {
67
+ doTransition ( { height : element [ 0 ] . scrollHeight + 'px' } )
68
+ . then ( function ( ) {
69
+ // This check ensures that we don't accidentally update the height if the user has closed
70
+ // the group while the animation was still running
71
+ if ( ! isCollapsed ) {
72
+ fixUpHeight ( scope , element , 'auto' ) ;
73
+ }
74
+ } ) ;
75
+ }
69
76
isCollapsed = false ;
70
77
} ;
71
78
72
79
var collapse = function ( ) {
73
80
isCollapsed = true ;
74
- fixUpHeight ( scope , element , element [ 0 ] . scrollHeight + 'px' ) ;
75
- doTransition ( { 'height' :'0' } ) ;
81
+ if ( initialAnimSkip ) {
82
+ initialAnimSkip = false ;
83
+ fixUpHeight ( scope , element , 0 ) ;
84
+ } else {
85
+ fixUpHeight ( scope , element , element [ 0 ] . scrollHeight + 'px' ) ;
86
+ doTransition ( { 'height' :'0' } ) ;
87
+ }
76
88
} ;
77
89
}
78
90
} ;
0 commit comments