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.

[Android] ScrollView events are not triggered when manually calling scrollTo

See original GitHub issue

Description

When having a ScrollView with onMomentumX events, these event will not be triggered on Android if the scroll was triggered by a manual scrollTo call.

I expected the events to be triggered on both platforms, but they were only triggered on iOS.

Reproduction

Here is a small demo app to reproduce the issue on rnplay: https://rnplay.org/apps/aPVzIg

The app has a state change (in this case, the width of the container) triggered by the ScrollView’s onMomentumScrollEnd event, and a timeout to manually call scrollTo after 2,000ms.

When running the sample on iOS, the state change will be triggered automatically after 2 seconds due to the onMomentumScrollEndevent being triggered post scrollTo.

When running the sample on Android, the state change will not be triggered automatically after 2 seconds (even though the scrollTo call could be seen to have been executed as the offset of the ScrollView changes).

When manually scrolling the view on Android, the event is being called as expected.

Additional Information

  • React Native version: 0.33
  • Platform: Android

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:8
  • Comments:18 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
tdekoningcommented, Dec 20, 2017

This is still an issue in RN 0.51

7reactions
tbarsbaycommented, Sep 25, 2017

Any chance we could re-open this? I’m still experiencing it on RN 0.48, Android 7.1 on a Nexus 6.

In particular, I’m using a FlatList which triggers onMomentumScrollEnd when I swipe between items but not when I call scrollToIndex on Android. But if I call scrollToIndex on iOS, it correctly calls onMomentumScrollEnd.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is ScrollView sometimes (!) not scrolling when scrollTo is ...
See this answer. ScrollView.scrollTo() may not working if some layout changes are being made when you called the method. And you are right, ......
Read more >
ScrollView - Android Developers
Called when a child does not want this parent and its ancestors to intercept touch events with ViewGroup#onInterceptTouchEvent(MotionEvent) .
Read more >
ScrollView - React Native
When true, the scroll view automatically centers the content when the content is smaller than the scroll view bounds; when the content is...
Read more >
ScrollView - How to determine if onScroll event is triggered ...
I would need to determine if a scroll view was scrolled programmatically or triggered by a user event. By default, if not moving...
Read more >
onScrollChanged() called twice for each scroll ... - Issue Tracker
Then try scrolling the content by dragging the scrollview up/down. ... Looking at the code, it appears that this is due to a...
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