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

Is there any way to restore scroll position while navigating back using browser button? #344

Closed jigneshInd closed 2 months ago

jigneshInd commented 4 years ago

Is there any way to restore scroll position while navigating back using browser button?

vitorpiovezam commented 4 years ago

Same here. I'm trying to implement this feature, in initial searchs I didn find anything to manipulate the ngx-infinite-scroll position.

gwenaellarmet commented 4 years ago

Hello, same question here, any news or idea how this could be done ?

orizens commented 4 years ago

hi. if you're asking about restoring the last triggered scrolled position - that's not straight forward and requires some work. internally, nis tracks the last scroll position - https://github.com/orizens/ngx-infinite-scroll/blob/master/src/services/scroll-register.ts#L23 by using the scrollstate class https://github.com/orizens/ngx-infinite-scroll/blob/7fc4390ebefb7e3040778d362b4ae8446ca6a10a/src/services/scroll-state.ts#L3

the above might be easy to expose.

a challenge would be how the last scroll position would actually be applied: the value for last scroll is px - the rendered list must include the same as it was when scrolled - this would have to managed externally.

OTHERWISE, you may track scroll by attaching a listener and save the scroll position - while you can use DOM's 'scrollTo' or element.scrollIntoView()

pausros commented 9 months ago

Any update on this feature perhaps? Thanks @orizens