orizens / ngx-infinite-scroll

Infinite Scroll Directive for Angular
https://www.npmjs.com/package/ngx-infinite-scroll
MIT License
1.23k stars 223 forks source link

Allow scroll distance to be calculated on fixed height instead of % of height #340

Closed Humberd closed 2 months ago

Humberd commented 4 years ago

The problem is that when I keep scrolling down the more items is added to the scroll element and and the less I have to scroll again to reach the infiniteScrollDistance threshold.

For example:

1st set of data -> I have to scroll 20 full wheels. 2nd set of data -> I have to scroll 15 full wheels. 3rd set of data -> I have to scroll 10 full wheels.

And it keeps getting lower and lower, so at the page 10 only a couple of scrolls would be sufficient to trigger the scroller. This is highly inefficient.

DarkMerge commented 4 years ago

+

githubuser88442 commented 4 years ago

Support. Would like to set a fixed/px value for the trigger as well. The library is really great, and it would be pretty much perfect if this were to be resolved.

yesninja commented 4 years ago

This was a problem at first for me as well as I loaded a ton of pages, made it unusable as the new page it loaded caused an immediate load of another page and ended up getting into a bad loop of loading and scrolling forever locking the UI and was a terrible UX. After trying to make my own that did what this library did, I ended up scratching all my efforts and instead just passed into infiniteScrollDistance a variable which uses the scrollbox height dividing it by the pixels I wanted then reversed the formula the library uses to get a percentage in order to get a number between 0.01 and 2. So as the scrollable area got larger, it took about the same amount of scroll wheels to load a new page each time no matter how large it got, seemed to work fine for my needs. Obviously an option to go by pixels instead would be great, however with a little math it can be done on your own.

MickL commented 2 years ago

This library seems to be absolutely useless without this issue being resolved. I wonder why anyone is using this how it is right now?

Initially it loads fine (e.g. 20% before the end) but as longer as the document gets the earlier it loads new pages. For me after only 2 loads the document is so long that it starts loading new pages even tho there are still 2 pages left to scroll and then it gets more on more. Soon there are 10 more pages left to scroll but it already loads another page and another ... Who ever wrote this didnt think to the end?

Instead of "emit when X % is scrolled" it should be "emit when X px away from the bottom"