当我向上滚动时,AngularJS的nginfinitesscroll会一直触发
AngularJS ngInfiniteScroll keeps firing as I scroll up
我向上滚动触发我的infiniteSubjects()
。但它应该只在向下滚动时触发它。我已经看了很多帖子,但还没有找到一个解决方案。我试过用infinite-scroll-disabled
。还尝试在底部的不同地方粘贴1003px高度的<div>
来占用空间。不行。:/
<div ng-app="mainApp" ng-controller="gridController" class="container">
<div class="row" infinite-scroll="infiniteSubjects()" infinite-scroll-distance="0" >
<div ng-repeat="subject in (filteredSubjects = (allSubjects | orderBy:subjectOrder | limitTo:subjectLimit))">
<div class="col-md-2 subject-card">
{{ subject.name }}
..more divs in here..
</div>
</div>
<div style="clear:both; height:1003px;"> </div>
</div>
</div>
Inside my controller:
$scope.infiniteSubjects = function() {
console.log("scrolling");
$scope.subjectLimit += 1;
};
我还进入了ng-infinite-scroll.js
文件,通过添加一些console.logs
windowBottom = $window.height() + $window.scrollTop();
console.log("WINDOWBOTTOM " + windowBottom);
elementBottom = elem.offset().top + elem.height();
console.log("ELEMENT BOTTOM" + elementBottom);
remaining = elementBottom - windowBottom;
console.log("REMAINING" + remaining);
页面加载时:
WINDOWBOTTOM 1194
ELEMENT BOTTOM 1194
REMAINING 0
我不认为窗口的底部和元素的底部应该是相同的开始。他们为什么会这样?
当我向下滚动,我的remaining
将增加-100
当我向上滚动时,我的remaining
将增加100
,但它永远不会变为正数,因为页面从0
在搜索了SO之后,我在一个类似的帖子上看到了另一个人的答案:nginfinitesscroll - loadMore()方法在每次鼠标滚动
时被调用我所需要做的就是在我的html顶部指定<!DOCTYPE html>
相关文章:
- 没有找到相关文章