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

Commit a72c635

Browse files
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
1 parent fd21214 commit a72c635

File tree

2 files changed

+1
-33
lines changed

2 files changed

+1
-33
lines changed

src/collapse/collapse.js

+1-17
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,7 @@ angular.module('ui.bootstrap.collapse',['ui.bootstrap.transition'])
2222

2323
var isCollapsed;
2424
var initialAnimSkip = true;
25-
scope.$watch(function (){ return element[0].scrollHeight; }, function (value) {
26-
//The listener is called when scollHeight changes
27-
//It actually does on 2 scenarios:
28-
// 1. Parent is set to display none
29-
// 2. angular bindings inside are resolved
30-
//When we have a change of scrollHeight we are setting again the correct height if the group is opened
31-
if (element[0].scrollHeight !== 0) {
32-
if (!isCollapsed) {
33-
if (initialAnimSkip) {
34-
fixUpHeight(scope, element, element[0].scrollHeight + 'px');
35-
} else {
36-
fixUpHeight(scope, element, 'auto');
37-
}
38-
}
39-
}
40-
});
41-
25+
4226
scope.$watch(attrs.collapse, function(value) {
4327
if (value) {
4428
collapse();

src/collapse/test/collapse.spec.js

-16
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,5 @@ describe('collapse directive', function () {
8686
expect(element.height()).toBeLessThan(collapseHeight);
8787
});
8888

89-
it('should shrink accordingly when content size inside collapse decreases on subsequent use', function() {
90-
scope.isCollapsed = false;
91-
scope.exp = false;
92-
scope.$digest();
93-
scope.isCollapsed = true;
94-
scope.$digest();
95-
scope.isCollapsed = false;
96-
scope.$digest();
97-
$timeout.flush();
98-
scope.exp = true;
99-
scope.$digest();
100-
var collapseHeight = element.height();
101-
scope.exp = false;
102-
scope.$digest();
103-
expect(element.height()).toBeLessThan(collapseHeight);
104-
});
10589
});
10690
});

0 commit comments

Comments
 (0)