Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling 'scrollToIndex' while manually scrolling causes blank content #45

Closed
AbdallaElabd opened this issue Sep 20, 2017 · 2 comments
Closed

Comments

@AbdallaElabd
Copy link

I have a specific case here where there's a button that scrolls to a specific index in the list. If I tap the button when the list is idle, it scrolls there and renders things just fine, but if the user is already scrolling in the list, it scrolls to its destination and shows blank content until I start scrolling again.

As far as I understood from the source code, there's a render stack that's prepared and it's being updated on scroll. The problem is that as the user is scrolling, if I force the list to go to a specific index with no animation, the renderStack loses track of the items it should render, until I start scrolling again, and then the renderStack gets updated and it renders things correctly again.

I hope my explanation made sense. Please let me know if I need to elaborate further.

@naqvitalha
Copy link
Collaborator

@abdallamohamed when you scroll with no Animation can you check if onScroll of scrollView or RecyclerListView is fired? I remember opening this issue on RN facebook/react-native#15563 . They closed it though, the problem was that onScroll on Android would not fire at all in some cases. Check if this is the same issue. Also, I assume you're trying on Android, if yes, try on iOS it should be fine. You might want to raise a new issue on RN if I'm right. Whatever we do here will be a workaround.

@AbdallaElabd
Copy link
Author

It's happening on iOS as well. Looks like it's a thing in react-native itself. I did a workaround by scrolling to the previous day first without animation and then scrolling to the destination day with animation. This will refresh the render stack and eliminate blank content.

this._recyclerListView.scrollToIndex(dayIndex - 1, false);
this._recyclerListView.scrollToIndex(dayIndex, true);

I'll close the issue for now. Thanks for the quick reply though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants