Skip to content

Commit 0557c30

Browse files
committed
fix(scrolling): Collection repeat requires JS scrolling
1 parent 08c37f9 commit 0557c30

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Diff for: js/angular/directive/content.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ function($timeout, $controller, $ionicBind, $ionicConfig) {
7171
element.addClass('scroll-content-false');
7272
}
7373

74+
var nativeScrolling = attr.overflowScroll === "true" || !$ionicConfig.scrolling.jsScrolling();
75+
76+
// collection-repeat requires JS scrolling
77+
if (nativeScrolling) {
78+
nativeScrolling = !element[0].querySelector('[collection-repeat]');
79+
}
80+
7481
return { pre: prelink };
7582
function prelink($scope, $element, $attr) {
7683
var parentScope = $scope.$parent;
@@ -116,7 +123,8 @@ function($timeout, $controller, $ionicBind, $ionicConfig) {
116123
} else {
117124
var scrollViewOptions = {};
118125

119-
if (attr.overflowScroll === "true" || !$ionicConfig.scrolling.jsScrolling()) {
126+
// determined in compile phase above
127+
if (nativeScrolling) {
120128
// use native scrolling
121129
$element.addClass('overflow-scroll');
122130

Diff for: test/unit/angular/directive/collectionRepeat.unit.js

+10
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,16 @@ describe('collectionRepeat', function() {
180180
expect(scrollView.options.getContentHeight).toBe(originalGetContentHeight);
181181
}));
182182

183+
it('should force JS scrolling', inject(function($compile, $rootScope) {
184+
var scope = $rootScope.$new();
185+
var content = $compile('<ion-content overflow-scroll="true">' +
186+
' <div collection-repeat="item in items" item-height="5" item-width="5"></div>' +
187+
' </ion-content')(scope);
188+
var scrollCtrl = content.data('$$ionicScrollController');
189+
$rootScope.$apply()
190+
expect(scrollCtrl.isNative()).toBe(false)
191+
}));
192+
183193
describe('automatic dimensions', function() {
184194
it('should use computed width/height', inject(function($window) {
185195
spyOn($window, 'getComputedStyle').andReturn({

0 commit comments

Comments
 (0)