To scroll a virtualized list using recursion until a specific row has entered the viewport, we can use the following steps:
scrollTo()
command to scroll the list to the desired top positionHere's an example implementation:
index.tsx1077 chars31 lines
To use this function, simply call it with the index of the desired row, selectors for the virtualized list and each row, and the height of each row:
index.tsx125 chars4 lines
Note: In the example implementation, I've used a fixed wait time of 500ms after each scroll to allow the list to render. Depending on the size of the list and the speed of the machine running the tests, you may need to adjust this time to ensure the list is fully rendered before checking for a visible row.
gistlibby LogSnag