From d307a1afae5969d1052b352b04ab61a03261b88d Mon Sep 17 00:00:00 2001 From: Sylvester Keil Date: Wed, 30 Sep 2015 11:15:31 +0200 Subject: [PATCH 1/2] 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). --- src/collapse/collapse.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/collapse/collapse.js b/src/collapse/collapse.js index 1b0044c35a..cff5efe115 100644 --- a/src/collapse/collapse.js +++ b/src/collapse/collapse.js @@ -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'}); } @@ -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); } } From ef49391895a1f4b262b84e3f9fad703dcd53b5c0 Mon Sep 17 00:00:00 2001 From: Sylvester Keil Date: Thu, 1 Oct 2015 14:26:13 +0200 Subject: [PATCH 2/2] fix(collapse): fix collapse animation timing --- src/collapse/test/collapse.spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/collapse/test/collapse.spec.js b/src/collapse/test/collapse.spec.js index 60547367b4..5083904493 100644 --- a/src/collapse/test/collapse.spec.js +++ b/src/collapse/test/collapse.spec.js @@ -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); }); @@ -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();