question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fix scroll position for dynamic contents

See original GitHub issue

I 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:open
  • Created 6 years ago
  • Reactions:3
  • Comments:42 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
immortalxcommented, Nov 1, 2019

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.

2reactions
naqvitalhacommented, Feb 21, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jump to last scroll position when dynamic Javascript content ...
I want it to scroll to the last scroll position when my JavaScript took care of loading the content without having to store...
Read more >
Preserve scroll position in prototypes - Figma Help Center
The preserve scroll position setting lets you keep the same scroll location when you transition between screens. This applies to vertical scroll depth,...
Read more >
Create scrollable artboards in XD - Adobe Support
Fix Position When Scrolling: Select to pin the elements to a fixed position to avoid scrolling with the content.
Read more >
Element.scrollLeft - Web APIs | MDN
If the element's direction is rtl (right-to-left), then scrollLeft is 0 when the scrollbar is at its rightmost position (at the start of...
Read more >
Reactive Scroll Position Restoration with RxJS - Medium
A common issue is that scroll position isn't as predictable inside of an… ... you started in fixing that bad UX with scroll...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found