Skip to content

Commit c35d691

Browse files
committed
refactor(scrollView): do not update if not rendered
1 parent 6410e1f commit c35d691

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

js/views/scrollView.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,11 @@ ionic.views.Scroll = ionic.views.View.inherit({
12451245
setDimensions: function(clientWidth, clientHeight, contentWidth, contentHeight) {
12461246
var self = this;
12471247

1248+
if (!clientWidth && !clientHeight && !contentWidth && !contentHeight) {
1249+
// this scrollview isn't rendered, don't bother
1250+
return;
1251+
}
1252+
12481253
// Only update values which are defined
12491254
if (clientWidth === +clientWidth) {
12501255
self.__clientWidth = clientWidth;

test/unit/angular/controller/scrollController.unit.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,6 @@ describe('$ionicScroll Controller', function() {
9595
expect(ctrl.scrollView.run).toHaveBeenCalled();
9696
});
9797

98-
it('should resize the scrollview on window resize', function() {
99-
setup();
100-
timeout.flush();
101-
spyOn(ctrl.scrollView, 'resize');
102-
ionic.trigger('resize', { target: window });
103-
expect(ctrl.scrollView.resize).toHaveBeenCalled();
104-
});
105-
10698

10799
it('should unbind window event listener on scope destroy', inject(function($window) {
108100
spyOn(ionic, 'on');
@@ -130,16 +122,6 @@ describe('$ionicScroll Controller', function() {
130122
expect(scope.$onScroll.mostRecentCall.args[0].scrollTop).toBe(3);
131123
});
132124

133-
it('.resize() should resize after timeout', inject(function($timeout) {
134-
setup();
135-
$timeout.flush();
136-
spyOn(ctrl.scrollView, 'resize');
137-
ctrl.resize();
138-
expect(ctrl.scrollView.resize).not.toHaveBeenCalled();
139-
$timeout.flush();
140-
expect(ctrl.scrollView.resize).toHaveBeenCalled();
141-
}));
142-
143125
it('.getScrollView', function() {
144126
setup();
145127
expect(ctrl.getScrollView()).toBe(ctrl.scrollView);

0 commit comments

Comments
 (0)