Anshul Kai
Anshul Kai

Reputation: 4088

React-Virtualized: Infinitely scrolling list

I'm encountering an issue while building an infinitely scrolling list. I need to maintain the scroll position but render more rows at the bottom. react-virtualized provides scrollTo but this doesn't seem enough since we do not have the current scrolledTo index. Calculating the scrollTo index dynamically using clientHeight, scrollHeight and scrollTop can only provide an approximation especially when the rows are of dynamic height.

Any suggestions?

Upvotes: 2

Views: 2716

Answers (1)

bvaughn
bvaughn

Reputation: 13487

I need to maintain the scroll position but render more rows at the bottom.

Adding more rows to the end/bottom will not affect scroll position.

react-virtualized provides scrollTo but this doesn't seem enough since we do not have the current scrolledTo index.

You pass the scroll-to prop to react-virtualized so you must have it. You can use the onScroll or onRowsRendered callback if you want to be notified of user-initiated scroll changes though.

Upvotes: 1

Related Questions