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

Fix collapse animation #4493

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/collapse/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@ angular.module('ui.bootstrap.collapse', [])

if ($animateCss) {
$animateCss(element, {
addClass: 'in',
easing: 'ease',
to: { height: element[0].scrollHeight + 'px' }
}).start().done(expandDone);
} else {
$animate.addClass(element, 'in', {
to: { height: element[0].scrollHeight + 'px' }
$animate.animate(element, {}, {
height: element[0].scrollHeight + 'px'
}).then(expandDone);
}
}

function expandDone() {
element.removeClass('collapsing')
.addClass('collapse')
.addClass('collapse in')
.css({height: 'auto'});
}

Expand All @@ -41,19 +40,18 @@ angular.module('ui.bootstrap.collapse', [])
.css({height: element[0].scrollHeight + 'px'})
// initially all panel collapse have the collapse class, this removal
// prevents the animation from jumping to collapsed state
.removeClass('collapse')
.removeClass('collapse in')
.addClass('collapsing')
.attr('aria-expanded', false)
.attr('aria-hidden', true);

if ($animateCss) {
$animateCss(element, {
removeClass: 'in',
to: {height: '0'}
}).start().done(collapseDone);
} else {
$animate.removeClass(element, 'in', {
to: {height: '0'}
$animate.animate(element, {}, {
height: '0'
}).then(collapseDone);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/collapse/test/collapse.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ describe('collapse directive', function() {
scope.exp = false;
scope.isCollapsed = false;
scope.$digest();
$animate.flush();
var collapseHeight = element.height();
scope.exp = true;
$animate.flush();
scope.$digest();
expect(element.height()).toBeGreaterThan(collapseHeight);
});
Expand All @@ -122,6 +122,7 @@ describe('collapse directive', function() {
scope.exp = true;
scope.isCollapsed = false;
scope.$digest();
$animate.flush();
var collapseHeight = element.height();
scope.exp = false;
scope.$digest();
Expand Down