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 position not being restored on rapid scrolling up #355

Closed RIPT1DE closed 2 months ago

RIPT1DE commented 4 years ago

Expected Behavior

It should restore the scroll position when the api call returns after scrolling all the way to the top.

Actual Behavior

When the api call returns, if the user has already scrolled all the way to the top by then, the scroll position isnt restored, instead, it jumps up to the top of the list again. (see demo). The scroll down behaviour is fine

Possible Solution

Steps To Reproduce / Demo (if applicable)

Demo

I have modified the modal section of the ngx-infinite-scroll demo to reproduce this issue. Timeouts have been added to the scroll up and scroll down handlers to simulate api calls, before appending new items to list. To reproduce the issue, simply open the modal and scroll rapidly to the top.

Context

I am using this as an infinite scroller for chat history. The history view is scrolled to the bottom by default, but as user scrolls up, older messages are fetched from the backend, and appended to the history. For now, it works fine, until the user scrolls very rapidly, and hits the top before api call returns.

Your Environment

todorpavlovic commented 4 years ago

I have the same problem...

svidoso commented 4 years ago

Same here

madmacc commented 4 years ago

Exact same problem v8.0.2 and v9.0.0. Any fix in the works?

silkcom commented 3 years ago

Same issue. Is there a way to turn off the check to see if the scroll position is 0? I only load more results when they reach the very top, which means that it's always a jarring experience.