adobe / uxp-optimized

Repository for uxp optimized react and javascript components.
MIT License
16 stars 7 forks source link

feature request: add ability to query for list of visible items #23

Closed alexander-riss closed 3 years ago

alexander-riss commented 3 years ago

our use case is that we would like to allow to e.g. let the outer component know which element range is currently visible, so we could only issue a scrollTo event when an element is requested that is out of view completely

krisnye commented 3 years ago

I added three new imperative functions that will allow you to handle this.

getRenderKeys:

https://github.com/adobe/uxp-optimized/blob/92caf1733e69cb924e2eac0793ae2f19e118e535/src/Virtualizer/VirtualizerApi.ts#L24

getItemRect

https://github.com/adobe/uxp-optimized/blob/92caf1733e69cb924e2eac0793ae2f19e118e535/src/Virtualizer/VirtualizerApi.ts#L29

getVisibleRect

https://github.com/adobe/uxp-optimized/blob/6ca2deb2a080d7b2d661794c49b3b320adcbb253/src/Virtualizer/VirtualizerApi.ts#L33

The sample uses these functions and logs the results here:

https://github.com/adobe/uxp-optimized/blob/92caf1733e69cb924e2eac0793ae2f19e118e535/src/devsample/SampleSelector.tsx#L70