-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(virtual-scroll): Add dynamic fixed size virtual scroll strategy #33045
Copy link
Copy link
Open
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/scrollingfeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesgemini-triagedLabel noting that an issue has been triaged by geminiLabel noting that an issue has been triaged by gemini
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/scrollingfeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesgemini-triagedLabel noting that an issue has been triaged by geminiLabel noting that an issue has been triaged by gemini
Type
Fields
Give feedbackNo fields configured for issues without a type.
Feature Description
Currently the provided virtual scroll strategy is only for fixed size. This is very restrictive.
In cdk experimental there is an autoSize strategy that determines the size of an item automatically but it is experimental and decides the size by itself.
I propose a new strategy for fixed, known but dynamic size.
For example if I have a list of items with some items being with 50px height and some with 80px height I can't use any default strategy for it but I also don't need autoSize. I know item 3 is 80px but item 6 is 50px which makes it easier to implement.
Using the new strategy I can express the dynamic (but known) size.
An example API for it is passing a function:
(index: number) => numberthat returns a pixel size based on given item index.One of the benefits is that fixed size is a specific case of the new strategy with the function returning the same size always (with a bit of worse performance) - so no need to create two default strategies as fixed (the current one) can be derived from the new strategy.
I created a stackblitz with such strategy and some use cases:
https://stackblitz.com/edit/stackblitz-starters-eey1ve9m
Use Case
To summarize it gives a lot of control for many use cases including the fixed size that exists today.