bvaughn / react-virtualized

React components for efficiently rendering large lists and tabular data
http://bvaughn.github.io/react-virtualized/
MIT License
26.1k stars 3.05k forks source link

please add the scrollToIndex or scrollToBottom function to the list #1765

Open z-lionel opened 1 year ago

z-lionel commented 1 year ago

When the list is first loaded, i want to scroll to the bottom it can work when i get the data, and set the value at scrollToIndex={data.length - 1} when i scroll to top it not problem, but i scroll down, it just jumping to the bottom

it can fixed by i reset scrollToIndex={-1}, but i have no way to know when the list first load and scroll to the bottom already

Akshh057 commented 1 year ago

We also faced this issue some time ago and we solved it through below method.

const onRowsRendered = (data) => {
                const { startIndex, stopIndex } = data;
                if (
                    scrollIndex !== -1 &&
                    (scrollIndex >= startIndex || scrollIndex <= stopIndex)
                ) {
                    setScrollIndex(-1);
                  }
  }