我在我的网站上使用ng-infinite-scroll Angular 指令,它总体上运行良好。然而,在测试时我注意到如果我快速滚动页面会跳回到顶部。下面是我的 html 和我的滚动功能。我认为问题在于如何$scope.busy
处理:
html:
<div class="row inner" infinite-scroll="loadImages()" infinite-scroll-distance="1" infinite-scroll-disabled="busy">
<h2 class="headline">{{event}}</h2>
<h3 class="headline">{{city}}, {{state}}</h3>
<div class="col-md-3 col-sm-4 col-xs-12 img-container" ng-repeat="photo in photos">
<a ng-href="{{photo.link}}" target="_blank" title="{{photo.text}}"><img ng-src="{{photo.img}}" onerror="imgError(this);" alt="" class="img-responsive insta" id="image"></a>
<div class="prof-circ" title="{{photo.username}}"><a ng-href="http://instagram.com/{{photo.username}}" target="_blank"><img ng-src="{{photo.profile}}" onerror="anonImg(this);" alt="" class="circular"></a></div>
</div>
控制器代码:
$scope.loadImages = function() {
if ($scope.busy) return;
$scope.busy = true;
$scope.limit += 20;
Events.get($scope.id,$scope.limit).success(function(response) {
$scope.photos = response.photos.reverse();
$scope.busy = false;
});
}