react-arborist icon indicating copy to clipboard operation
react-arborist copied to clipboard

How to get the current scroll position and the overall height of the scroll container?

Open ivan-palatov opened this issue 2 years ago • 1 comments

I want to make a tree which would load data asynchronously upon user opening a tree node (which seems easy to do here) or upon scrolling down the tree root (in my use case root would have not only folders, but also lots and lots of items (thoughsands of them) and it wouldn't be a great experience for a user to load them all at once). Is there a way to get the overall height of the scroll container and current scroll position to make the latter possible? Or if not, is there a better way to do what I need?

ivan-palatov avatar May 21 '22 16:05 ivan-palatov

Hi @ivan-palatov, I'm so glad you are using react-arborist for this use case. I don't need to load data async yet for my use cases, but I've wondered how well the library would hold up to it.

This library depends on https://react-window.vercel.app/#/api/FixedSizeList for listing the items. It supports everything you need to get the scroll position, but it looks like react-arborist doesn't provide access to them. It will be a simple update to react-arborist to give you access to those methods.

However, react-arborist should be able to handle up to around 10,000 items! Give it a try and see how far you can get.

I'll leave this open as a ticket to provide access to those scroll methods.

jameskerr avatar May 21 '22 17:05 jameskerr