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

Scroll event not fired when scrolling fast to the bottom #385

Closed barisbikmaz closed 2 years ago

barisbikmaz commented 3 years ago

Expected Behavior

When I scroll to the bottom of a list the "scroll" event should be fired.

Actual Behavior

When I have e.g. infiniteScrollThrottle =500 defined I scroll fast to the bottom of a list the scroll event is not fired.

Possible Solution

Possible solution is to set infiniteScrollThrottle=0. Root causee seems to be the change from sampleTime to throttleTime. ThrottleTime does fire on next scroll but when you scroll to the bottom there is no next scroll.

Steps To Reproduce / Demo (if applicable)

Scroll Problem

Your Environment

DonutLaser commented 3 years ago

I'm experiencing this as well

IT-Smile commented 3 years ago

I have the same problem. It is the same for the up scroll.

IT-Smile commented 3 years ago

Root causee seems to be the change from sampleTime to throttleTime. ThrottleTime does fire on next scroll but when you scroll to the bottom there is no next scroll.

I found the same conclusion. Maybe setting the trailing attribute from throttleTime to true, could help here.

We could try something like this in scroll-register at line 70. obs = obs.pipe(throttleTime(options.throttle, undefined, { leading: true, trailing: true }));

Idea: https://stackoverflow.com/questions/37146081/rxjs-throttle-behavior-get-first-value-immediately Explanation about how it works: https://stackoverflow.com/questions/57059666/how-does-throttletime-operators-config-parameter-work-throttleconfig

EDIT: It seems to solve the problem.

RifkyLTF commented 2 years ago

I was having the same issue. Adding [infiniteScrollThrottle]="0" will fix the problem but you need to handle your load more function carefully because scrolled event will trigger instantly without having to wait user stopped scrolling

naveedahmed1 commented 2 years ago

In my case the http requests gets cancelled when I scroll too fast, any help would be appreciated.

rost-kndrtv commented 2 years ago

Any updates regarding this issue? Because I'm also facing the same issues in my app and I'm wondering if there is chance to get a fix for it.

orizens commented 2 years ago

all, version 13 has been released. please feel free to create a pr for this.

sagrawal31 commented 2 years ago

Upgrading to v13 of this library fixes the issue 👏🏻