From a72c635c7669933204c17bf85cfe3d4fc350c73a Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Mon, 11 Nov 2013 19:03:37 +0100 Subject: [PATCH] fix(collapse): remove element height watching For unclear reasons the directive was watching DOM element's height which incurs performance penalty. Normally this watching shouldn't be necessery as collapsible elements should get height: auto; Closes #1222 --- src/collapse/collapse.js | 18 +----------------- src/collapse/test/collapse.spec.js | 16 ---------------- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/src/collapse/collapse.js b/src/collapse/collapse.js index d0a33b454f..d36c9a438f 100644 --- a/src/collapse/collapse.js +++ b/src/collapse/collapse.js @@ -22,23 +22,7 @@ angular.module('ui.bootstrap.collapse',['ui.bootstrap.transition']) var isCollapsed; var initialAnimSkip = true; - scope.$watch(function (){ return element[0].scrollHeight; }, function (value) { - //The listener is called when scollHeight changes - //It actually does on 2 scenarios: - // 1. Parent is set to display none - // 2. angular bindings inside are resolved - //When we have a change of scrollHeight we are setting again the correct height if the group is opened - if (element[0].scrollHeight !== 0) { - if (!isCollapsed) { - if (initialAnimSkip) { - fixUpHeight(scope, element, element[0].scrollHeight + 'px'); - } else { - fixUpHeight(scope, element, 'auto'); - } - } - } - }); - + scope.$watch(attrs.collapse, function(value) { if (value) { collapse(); diff --git a/src/collapse/test/collapse.spec.js b/src/collapse/test/collapse.spec.js index d04a8b3c90..d3784ad4c6 100644 --- a/src/collapse/test/collapse.spec.js +++ b/src/collapse/test/collapse.spec.js @@ -86,21 +86,5 @@ describe('collapse directive', function () { expect(element.height()).toBeLessThan(collapseHeight); }); - it('should shrink accordingly when content size inside collapse decreases on subsequent use', function() { - scope.isCollapsed = false; - scope.exp = false; - scope.$digest(); - scope.isCollapsed = true; - scope.$digest(); - scope.isCollapsed = false; - scope.$digest(); - $timeout.flush(); - scope.exp = true; - scope.$digest(); - var collapseHeight = element.height(); - scope.exp = false; - scope.$digest(); - expect(element.height()).toBeLessThan(collapseHeight); - }); }); }); \ No newline at end of file