ngInfiniteScroll触发所有滚动事件

ngInfiniteScroll Triggers On All Scroll Events

本文关键字:滚动 事件 ngInfiniteScroll      更新时间:2023-09-26

我正在使用ngInfiniteScroll在我的网站上启用无限滚动。为了让它发挥作用,我不得不将外部div的高度设置为如下所示的值。如果我不这样做,无限滚动功能将触发

<div style="height: 1px">
   <post post-item="item" feed-items="items.feed" feed-name="feedName" ng-repeat="item in items.feed"></post>
   <a style="bottom-padding 7%" infinite-scroll="nextPosts()" infinite-scroll-distance="1" href ng-click="nextPosts()" class="show-more">No more posts to show </a>   
</div>

然而,设置高度:1px有点搞砸了我的css样式,我觉得这在技术上是作弊的,尤其是因为我必须在上做底部填充

有人知道在不使用style="height:1px 的情况下,我可以在所有滚动事件中不触发无限滚动的方法吗

我已经看过这个帖子了,但它并没有真正的帮助。如何防止浮动元素的父级塌陷?

谢谢!

http://binarymuse.github.io/ngInfiniteScroll/documentation.html

通常,您将对元素使用infiniteScroll指令包含另一个元素,该元素使用ngRepeat来显示一系列基于数组(或对象)的元素;传入的表达式infinite-scroll属性通常会添加附加元素扩展ngRepeat

也许你可以试试基本的例子:

<div infinite-scroll="nextPosts()">
   <post post-item="item" feed-items="items.feed" feed-name="feedName" ng-repeat="item in items.feed"></post>
</div>