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

Commit 82cd2d4

Browse files
inukshukwesleycho
authored andcommitted
Fix collapse animation
Set class 'in' at the end of the animation to mimick the behaviour of TWBS js. This removes scrollbars which are otherwise visible during the animation in certain configurations (most notably when used inside navbars).
1 parent 13be7b7 commit 82cd2d4

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Diff for: src/collapse/collapse.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,19 @@ angular.module('ui.bootstrap.collapse')
9797

9898
if ($animateCss) {
9999
$animateCss(element, {
100-
addClass: 'in',
101100
easing: 'ease',
102101
to: { height: element[0].scrollHeight + 'px' }
103102
}).start().done(expandDone);
104103
} else {
105-
$animate.addClass(element, 'in', {
106-
to: { height: element[0].scrollHeight + 'px' }
104+
$animate.animate(element, {}, {
105+
height: element[0].scrollHeight + 'px'
107106
}).then(expandDone);
108107
}
109108
}
110109

111110
function expandDone() {
112111
element.removeClass('collapsing')
113-
.addClass('collapse')
112+
.addClass('collapse in')
114113
.css({height: 'auto'});
115114
}
116115

@@ -126,19 +125,18 @@ angular.module('ui.bootstrap.collapse')
126125
.css({height: element[0].scrollHeight + 'px'})
127126
// initially all panel collapse have the collapse class, this removal
128127
// prevents the animation from jumping to collapsed state
129-
.removeClass('collapse')
128+
.removeClass('collapse in')
130129
.addClass('collapsing')
131130
.attr('aria-expanded', false)
132131
.attr('aria-hidden', true);
133132

134133
if ($animateCss) {
135134
$animateCss(element, {
136-
removeClass: 'in',
137135
to: {height: '0'}
138136
}).start().done(collapseDone);
139137
} else {
140-
$animate.removeClass(element, 'in', {
141-
to: {height: '0'}
138+
$animate.animate(element, {}, {
139+
height: '0'
142140
}).then(collapseDone);
143141
}
144142
}

0 commit comments

Comments
 (0)