我遇到了角度无限滚动在移动设备上不起作用的问题 - 在小米 Redmi Note 4 和三星 Galaxy 4 上进行了测试。
我的代码在 PC 和IOS设备上正常工作。
问题仅在移动设备上重现。
也许有人面临同样的问题?你能给我一些建议吗?
$scope.loadNews = function() {
if ($scope.position > $scope.allNews.length) return;
if ($scope.allNews.length > $scope.news.length) {
var partOfNews = $scope.getPartOfEntities($scope.newsPosition, $scope.scrollNewsCount, 0);
for (var i = 0; i < partOfNews.length; i++) {
$scope.news.push(partOfNews[i]);
}
}
};
<div ng-hide="showSpinner">
<div infinite-scroll='loadNews()' infinite-scroll-distance='0.5'>
<hr>
<news data="news"></news>
</div>
</div>
handler = function() {
var elementBottom, remaining, shouldScroll, windowBottom;
windowBottom = $window.height() + $window.scrollTop();
elementBottom = elem.offset().top + elem.height();
remaining = elementBottom - windowBottom;
shouldScroll = remaining <= $window.height() * scrollDistance;
if (shouldScroll && scrollEnabled) {
if ($rootScope.$$phase) {
return scope.$eval(attrs.infiniteScroll);
} else {
return scope.$apply(attrs.infiniteScroll);
}
} else if (shouldScroll) {
return checkWhenEnabled = true;
}
};
var applied = false;
var touchmover = function () {
if ( ! applied) {
applied = true;
$window.on('touchend', handler);
}
};
$window.on('touchmove', handler);
scope.$on('$destroy', function() {
$window.off('touchend', handler);
applied = false;
return $window.off('touchmove', touchmover);
});