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

前端 未结 7 934
佛祖请我去吃肉
佛祖请我去吃肉 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:29

    I have solved my problem.

    One of foundation properties that NIS (ngInfiniteScroll) measure, are $containerand $elem

    1. $container is the parent of the scrolled elements Element.
    2. $elem is the Element that contain the scrolled elements.

    Example

    <$container> 
        <$elem> 
            
            
            
            
        
    
    

    What NIS is trying to do, is to calculate on each mouse scroll, if enabled, the relation between these two elements, and check if $elem is taller than $container, and then scroll down or not. (it also check other properties like - distance, immediate-check & disabled).

    So this relation between this two fundamental elements, is crucial for the understanding & debugging of NIS.

    So my problem was exactly that - The $container and $elem were equal at their height.
    I had fixed css height values (100%) on both elements (mainly cause I read in the documentation that I must pass height), and by mistake I fixed $elemwhich was totally wrong.

    Secondly - infinite-scroll-distance can cause this to happen as well. If the value that you're setting is high (let's say 2), and your loadMore() method don't populate enough items, even if you disable runtime of the method, than you will get infinite loadmore() executions.

提交回复
热议问题