Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 81e014a

Browse files
fix(collapse): dont animate height changes from 0 to 0
Closes #1424
1 parent 70af344 commit 81e014a

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/collapse/collapse.js

+16-15
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,27 @@ angular.module('ui.bootstrap.collapse',['ui.bootstrap.transition'])
4545
return currentTransition;
4646
};
4747

48-
var expand = function() {
48+
var expand = function () {
49+
isCollapsed = false;
4950
if (initialAnimSkip) {
5051
initialAnimSkip = false;
51-
if ( !isCollapsed ) {
52-
fixUpHeight(scope, element, 'auto');
53-
element.addClass('in');
54-
}
52+
expandDone();
5553
} else {
56-
doTransition({ height : element[0].scrollHeight + 'px' })
57-
.then(function() {
58-
// This check ensures that we don't accidentally update the height if the user has closed
59-
// the group while the animation was still running
60-
if ( !isCollapsed ) {
61-
fixUpHeight(scope, element, 'auto');
62-
element.addClass('in');
63-
}
64-
});
54+
var targetElHeight = element[0].scrollHeight;
55+
if (targetElHeight) {
56+
doTransition({ height: targetElHeight + 'px' }).then(expandDone);
57+
} else {
58+
expandDone();
59+
}
6560
}
66-
isCollapsed = false;
6761
};
62+
63+
function expandDone() {
64+
if ( !isCollapsed ) {
65+
fixUpHeight(scope, element, 'auto');
66+
element.addClass('in');
67+
}
68+
}
6869

6970
var collapse = function() {
7071
isCollapsed = true;

0 commit comments

Comments
 (0)