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

Commit

Permalink
Fix collapse animation
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
inukshuk authored and wesleycho committed Oct 19, 2015
1 parent 13be7b7 commit 82cd2d4
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/collapse/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,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 @@ -126,19 +125,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

0 comments on commit 82cd2d4

Please sign in to comment.