ngInfiniteScroll - loadMore() method gets called on every mouse-scroll

前端 未结 7 933
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-02 12:13

Solution below on the comments.

Problem: My loadMore() method gets executed on every container\'s scroll.

Meaning: loa

相关标签:
7条回答
  • 2021-02-02 12:46

    This might seem obvious, but it evaded me for a day.

    I followed the example shown in the image on the homepage of NIS:

    The important part to notice is the scroll distance:

    infinite-scroll-distance="3"
    

    According to the documentation,

    if the browser window is 1000 pixels tall and infinite-scroll-distance is set to 2, the infinite scroll expression will be evaluated when the bottom of the element is within 2000 pixels of the bottom of the browser window. Defaults to 0 (e.g. the expression will be evaluated when the bottom of the element crosses the bottom of the browser window).

    During my development, I only had ~50 items displaying, and thought, albeit incorrectly, that NIS was firing infinitely. In fact, it was just trying to fill up ~4000 pixels.

    TL;DR: Remove (or at least reduce) infinite-scroll-distance if you have it set.

    0 讨论(0)
提交回复
热议问题