You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Android] ScrollView momentum not stopping when calling scrollTo programmatically #32235
When scrolling down a long ScrollView or FlatList on Android and calling scrollTo programmatically while the ScrollView's momentum is still going, the momentum does not stop and the resulting scrolling is stuttering and simply wrong.
React Native version / Platform
0.65.1 / Android
With 0.63.4, this bug was not yet present.
Steps To Reproduce
Render a ScrollView (or FlatList) with long content and a button with onPress={() => scrollViewRef.scrollTo({ y: 0, animated: true })}.
Scroll quickly down with your finger so that a momentum occurs.
Press the button while the momentum is still going.
Expected Results
The momentum should stop and the ScrollView should scroll to its beginning.
Possible reason
It seems that the reason for this bug lies in the following commit: 10314fe
Edit: As a workaround, you can use scrollTo function from react-native-reanimated: tomekzaw/Issue32235@81f34c4 Note that it only works for animated: true (smooth scroll), for animated: false (immediate scroll) the issue still persists.
workaround.mov
Edit: After many hours of debugging, I came up with the following change that seems to resolve the issue. I will submit a pull request with this change soon.
public void scrollTo(int x, int y) {
+ mScroller.abortAnimation();
super.scrollTo(x, y);
ReactScrollViewHelper.updateFabricScrollState(this);
setPendingContentOffsets(x, y);
}
Activity
reepush commentedon Nov 29, 2021
10314fe made scrolling worse on Android :(
yiuyiu commentedon Jan 11, 2022
Running into the same issue.
RosCoder commentedon Dec 17, 2022
React Native 0.70.6. The same issue..
bolan9999 commentedon Dec 30, 2022
Any update? fk rn
moremorefun commentedon Jan 11, 2023
scrollViewRef.scrollTo({ y: xxx, animated: false})Nor did it move to the specified location, the new target location did not overwrite the old target location
anatoleblanc commentedon Feb 1, 2023
Would love to have an update on this :)
stitesExpensify commentedon Feb 6, 2023
I would also appreciate an update if anyone has found a solution
halftheopposite commentedon Feb 7, 2023
This is also something we are facing on Android only (RN
0.70.1), and for a little bit more context:onScrollreports normal scrolling values (ex: 1200, 1220, 1240, etc.)scrollTotoy: 0with an outside actiononScrollcorrectly reports a scroll ofy: 0once, but then continues with its momentum (ex: 1240, 0, 1260, 1280, etc.)moremorefun commentedon Feb 7, 2023
same issue
tomekzaw commentedon Feb 7, 2023
The issue still persists on 0.71.2, both on Android emulator as well as physical device.
I've made a repro: https://github.com/tomekzaw/Issue32235
Here's a video recording:
recording.mov
I will investigate this issue further.
Edit: As a workaround, you can use
scrollTofunction from react-native-reanimated: tomekzaw/Issue32235@81f34c4 Note that it only works foranimated: true(smooth scroll), foranimated: false(immediate scroll) the issue still persists.workaround.mov
Edit: After many hours of debugging, I came up with the following change that seems to resolve the issue. I will submit a pull request with this change soon.
public void scrollTo(int x, int y) { + mScroller.abortAnimation(); super.scrollTo(x, y); ReactScrollViewHelper.updateFabricScrollState(this); setPendingContentOffsets(x, y); }fixed.mov
Fix Android ScrollView not responding to Keyboard events when nested …
Fix Android ScrollView not responding to Keyboard events when nested …
Fix Android ScrollView not responding to Keyboard events when nested …