How to make infinite scrolling in both directions, up and down. I am using the InfiniteLoader and the List, both are react-virtualized components. I have a list of timestamps with initial date-time range. From there the list should be infinite in both directions. Currently, scroll-down to the bottom of the List will trigger the function _loadMoreRows(). However, I would like to trigger the _loadMoreRows() with the same functionality when scrolling in the direction up.
react-virtualized InfiniteLoader in both directions, top and bottom
2.6k views Asked by sara.aleksi At
1
I have it working now :) Everything is fine. The
threshold
prop of the<InfiniteLoader>
defines the threshold number of indices before the start/end of theList
when to prefetch data, i.e. trigger_loadMoreRows()
.The first and the last item in
this.state.items
should have their correspondingloadedRowsMap
set toundefined
after the initial data fetch.Before displaying the list, a
scrollToIndex
prop of the<List>
component should be set to the middle of the list, i.e.rowCount/2
. This number should satisfy the equationFunction
_isRowLoaded()
will checkloadedRowsMap[index]
. If it is set toSTATUS_LOADED
orSTATUS_LOADING
(internal constants used inside theInfiniteLoader
) it will not trigger_loadMoreRows()
. If it is set toundefined
, then it will trigger_loadMoreRows()
.With this setup, trigering
_loadMoreRows()
works in both scroll directions, up and down.