I am using the List
and WindowScroller
in react-virtualized to display logs. It seems that there is no good way to implement the auto-follow. It seems pretty easy to scroll to the bottom with scrollToIndex
. But it is pretty hard to know whether we are at the bottom of the page. the document.body.clientHeight
is much smaller than the scrollTop
provided by WindowScroller
. How could we implement this feature? Thanks.
Asked
Active
Viewed 92 times
0
1 Answers
0
you can use the prop "scrollToIndex" when his value is equal to your row count
render(): React.Element<AutoSizer> {
const { data, ...otherProps } = this.props;
return (
<AutoSizer onResize={this.onResizeHandler}>
{({ width, height }) => (
<List
{...otherProps}
deferredMeasurementCache={this.cache}
rowHeight={this.cache.rowHeight}
rowCount={data.length}
forceUpdateGrid={data}
rowRenderer={this.rowRenderer}
scrollToIndex={data.length - 1}
onScroll={this.onScrollHandler}
height={height}
width={width}
/>
)}
</AutoSizer>
);
}

Shem Levy
- 66
- 3