Fix scroll position for dynamic contents
See original GitHub issueI want to create an infinite scroll view using recyclerlistview in both direction (up and down)
When I load more contents , the following code executed
const dataProvider = new DataProvider((r1, r2) => {
return r1 !== r2;
});
this.setState({
dataProvider: dataProvider.cloneWithRows(myContents)
});
Here the scroll offset will reset to zero and scroll go to the top
I use scrollToOffset
to change the offset to getCurrentScrollOffset()+heightOfNewContents
when scrolling to up direction , scrollToOffset
works accuracy well but I see a small view refresh , the view become blank for a fraction of second
I find that changing dataProvider
is not the cause , scrollToOffset
is the reason because If I don’t change data and just call scrollToOffset
I see the view become blank for fraction of second , I test with a simple PureComponent
and I’m sure scrollToOffset
is problem not the CellContainer
view itself
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:42 (5 by maintainers)
Top GitHub Comments
Version 2.0.13-alpha.1
If i understand the issue, I’m having the same problems with a list of fixed size items. It’s a grid of pictures. Whenever a push new data the scroll position goes up a little causing a “flick”, “bump” effect. This is the normal behavior? I have this working with Flatlist, since I’m new to this library, I’m not sure if is up to me to handle this.
That’s the only issue so far, the performance is really great even with thousands of pictures.
Try this https://snack.expo.io/S1zKr6tPf. Even though it’s a hack (uses private api) but it certainly proves that it is possible. Also, note none of these solutions work in between a scroll. Maybe we can transform the whole list instead to correct the offset. Post the animation work we will be introducing stableIds which will improve this further and the flicker will go away automatically without increasing
renderAheadOffset
like I did in the sample.