Feature request
Infinite scroll in both direction
Currently the infinite scroll is not possible in both direction
I am using horizontal virtual scroll, I need to provide infinite scroll in both direction and keep the current index always in center of the view port
Assume the array is
[0][1][2][3][4][5][6][7][8][9]
currIndex
|
[6][7] | [8][9][0][1][2] | [3][4][5]
Not rendered | Rendered | Not rendered
Let's say user go to viewport.scrollToIndex(2)
currIndex
|
[8][9] | [0][1][2][3][4] | [5][6][7]
Not rendered | Rendered | Not rendered
Angular: 7.0.1
Material: 7.0.2
I have tried to implement it with current functionality (7.0.2), can anyone check this example, maybe it is simple!
stackblitz
stackoverflow question
I would suggest using a custom data source for this (see the custom data source example from the virtual scroll docs)
@mmalerba I tried to implement it in this stackblitz but I still haven't got it right
here's an example that adds new copies of the data when you get near the end of the list: https://stackblitz.com/edit/angular-qpsjxm?file=app/cdk-virtual-scroll-data-source-example.ts
@mmalerba Thanks! that looks good! but is it possible to do the same for the opposite direction? I want to make the same for scrolling up
You could start off scrolled to the middle of the list, that would allow the user to scroll up or down
@mmalerba I tried to apply the same for scrolling up, I am very close to get the solution but scrolling up is reaching the top, it should work like scrolling to bottom.
Here is my trial
I used this.viewPort.scrollToIndex(range.start); to scroll down when new items are added to the top, but it is now working as expected, any idea how to fix it?
Thanks!
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
here's an example that adds new copies of the data when you get near the end of the list: https://stackblitz.com/edit/angular-qpsjxm?file=app/cdk-virtual-scroll-data-source-example.ts