Skip to content

Commit

Permalink
fix(scrolling): Collection repeat requires JS scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
perrygovier committed May 1, 2015
1 parent 08c37f9 commit 0557c30
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
10 changes: 9 additions & 1 deletion js/angular/directive/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ function($timeout, $controller, $ionicBind, $ionicConfig) {
element.addClass('scroll-content-false');
}

var nativeScrolling = attr.overflowScroll === "true" || !$ionicConfig.scrolling.jsScrolling();

// collection-repeat requires JS scrolling
if (nativeScrolling) {
nativeScrolling = !element[0].querySelector('[collection-repeat]');
}

return { pre: prelink };
function prelink($scope, $element, $attr) {
var parentScope = $scope.$parent;
Expand Down Expand Up @@ -116,7 +123,8 @@ function($timeout, $controller, $ionicBind, $ionicConfig) {
} else {
var scrollViewOptions = {};

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

Expand Down
10 changes: 10 additions & 0 deletions test/unit/angular/directive/collectionRepeat.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@ describe('collectionRepeat', function() {
expect(scrollView.options.getContentHeight).toBe(originalGetContentHeight);
}));

it('should force JS scrolling', inject(function($compile, $rootScope) {
var scope = $rootScope.$new();
var content = $compile('<ion-content overflow-scroll="true">' +
' <div collection-repeat="item in items" item-height="5" item-width="5"></div>' +
' </ion-content')(scope);
var scrollCtrl = content.data('$$ionicScrollController');
$rootScope.$apply()
expect(scrollCtrl.isNative()).toBe(false)
}));

describe('automatic dimensions', function() {
it('should use computed width/height', inject(function($window) {
spyOn($window, 'getComputedStyle').andReturn({
Expand Down

0 comments on commit 0557c30

Please sign in to comment.