2017-03-22 113 views
0

我面临着角无限滚动无法在移动设备上工作的问题 - 在小蜜红米手机注4和三星Galaxy测试4.为什么ngInfiniteScroll(无限滚动)无法在移动设备上工作?

我的代码工作正常在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); 
 
     });

回答

0

您可以使用基于滚动一段简单的代码

$('#news').bind('scroll', function(){ if($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight){ //alert(1); loadNews(); } });

+0

我的问题是一家致力于ngInfiniteScroll 。我没有试图找到解决这个问题的替代方法。 –

相关问题