-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
ScrollView weird behaviour when there are less items #42874
Comments
|
Running into the same issue, using React Native 0.73.4. I have only been able to reproduce on physical Android devices. |
I also have this issue. I can reproduce this in physical Android device (API 33) and Android simulator (API 34). So far, no problem on iOS simulator. I actually wanted to write this earlier. I remember i get this issue since i upgraded the RN to 0.73.0 from 0.72.7, until now currently on 0.73.4. |
Running into the same issue, using React Native 0.72.10. |
Running into the same issue, using React Native 0.73.4. Reproducible on Android only Steps to Reproduce
Demohttps://snack.expo.dev/@uvrubel/rn-scrollview-horizontal screen-20240227-111557.mp4 |
Can confirm this is not something that was here before (but cannot easily bisect). |
After testing with Snack, doesn't happen with SDK 49 but happens on 50. Looking through the commits now. |
30c7e9d is the culprit! |
I'll have to check tomorrow ! I'm home now 😬 |
30c7e9d#diff-067e69cd88e616e9605533a4be612685b607a7d1cd29f854ee77d713113cb170R612-R614 is the change that breaks things |
Huh. That was to fix another bug, where flinging to the edge would sometimes start scrolling backwards (#38236 is one report, though I think I saw others after the fact). The version clamp was based on a linked Android bug report being fixed, and seeing incorrect behavior in emulator. So I think there might be a couple possibilities:
|
Even if i fully downgrade android scroll logic (ReactAndroid/src/.../views/scroll) to 0.72.4 version, bug is still reproduced. Interesting fact, that shopify's flashlist reproduce this bug too. Tested on emulator 30, 34 api RN 0.73.5 |
Yep you are using prefab probably! |
This is the line that breaks it for me 30c7e9d#diff-067e69cd88e616e9605533a4be612685b607a7d1cd29f854ee77d713113cb170R612-R614. (Verified with breakpoints) |
Yeah, my mistake. I'm forgot bout prefabs. Thank you |
…Less Length than Scrolling View Summary: Fixes facebook#42874 ## Sumary D9405703 added some custom logic for Flings, to support FlatList scenarios where content is being added on the fly, during Fling animation. This works by allowing start Fling to not have bounds, then correcting/cancelling Fling when overscroll happens over a bound that would normally be allowed. This has some math to try to determine max content length, and will clamp to this when scrolling over it. This logic is incorrect when content length is less than scrollview length, and we end up snapping to a negative offset. This change adds clamping, so that we don't snap to negative position in horizontal scroll view. This clamping was already indirectly present on vertical scroll view. https://www.internalfb.com/code/fbsource/[b43cdf9b2fec71f5341ec8ff2d47e28a066f052e]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java?lines=609 ## Test Plan Above issue no longer reproes. Flinging while content is being added to horizontal FlatList still works correctly. Changelog: [Android][Fixed] - Fix Android Horizontal ScrollView OverScroll Fling when Content View Less Length than Scrolling View Differential Revision: D55108818
same issue here, any solutions? |
Look above |
…ScrollView length (#43563) Summary: Pull Request resolved: #43563 Fixes #42874 ## Sumary D9405703 added some custom logic for Flings, to support FlatList scenarios where content is being added on the fly, during Fling animation. This works by allowing start Fling to not have bounds, then correcting/cancelling Fling when overscroll happens over a bound that would normally be allowed. This has some math to try to determine max content length, and will clamp to this when scrolling over it. This logic is incorrect when content length is less than scrollview length, and we end up snapping to a negative offset. This change adds clamping, so that we don't snap to negative position in horizontal scroll view. This clamping was already indirectly present on vertical scroll view. https://www.internalfb.com/code/fbsource/[b43cdf9b2fec71f5341ec8ff2d47e28a066f052e]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java?lines=609 ## Test Plan Above issue no longer reproes. Flinging while content is being added to horizontal FlatList still works correctly. Changelog: [Android][Fixed] - Fix Android HorizontalScrollView fling when content length less than ScrollView length Reviewed By: javache Differential Revision: D55108818 fbshipit-source-id: 7cf0065f9f92832cc2606d1c7534fc150407b9c9
…ScrollView length (#43563) Summary: Pull Request resolved: #43563 Fixes #42874 ## Sumary D9405703 added some custom logic for Flings, to support FlatList scenarios where content is being added on the fly, during Fling animation. This works by allowing start Fling to not have bounds, then correcting/cancelling Fling when overscroll happens over a bound that would normally be allowed. This has some math to try to determine max content length, and will clamp to this when scrolling over it. This logic is incorrect when content length is less than scrollview length, and we end up snapping to a negative offset. This change adds clamping, so that we don't snap to negative position in horizontal scroll view. This clamping was already indirectly present on vertical scroll view. https://www.internalfb.com/code/fbsource/[b43cdf9b2fec71f5341ec8ff2d47e28a066f052e]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java?lines=609 ## Test Plan Above issue no longer reproes. Flinging while content is being added to horizontal FlatList still works correctly. Changelog: [Android][Fixed] - Fix Android HorizontalScrollView fling when content length less than ScrollView length Reviewed By: javache Differential Revision: D55108818 fbshipit-source-id: 7cf0065f9f92832cc2606d1c7534fc150407b9c9
In case someone needs a fix without upgrading, setting <ScrollView horizontal contentContainerStyle={{ width: "100%" }}> |
…ScrollView length (#43563) Summary: Pull Request resolved: facebook/react-native#43563 Fixes facebook/react-native#42874 ## Sumary D9405703 added some custom logic for Flings, to support FlatList scenarios where content is being added on the fly, during Fling animation. This works by allowing start Fling to not have bounds, then correcting/cancelling Fling when overscroll happens over a bound that would normally be allowed. This has some math to try to determine max content length, and will clamp to this when scrolling over it. This logic is incorrect when content length is less than scrollview length, and we end up snapping to a negative offset. This change adds clamping, so that we don't snap to negative position in horizontal scroll view. This clamping was already indirectly present on vertical scroll view. https://www.internalfb.com/code/fbsource/[b43cdf9b2fec71f5341ec8ff2d47e28a066f052e]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java?lines=609 ## Test Plan Above issue no longer reproes. Flinging while content is being added to horizontal FlatList still works correctly. Changelog: [Android][Fixed] - Fix Android HorizontalScrollView fling when content length less than ScrollView length Reviewed By: javache Differential Revision: D55108818 fbshipit-source-id: 7cf0065f9f92832cc2606d1c7534fc150407b9c9
Was it fixed in both 0.73 and 0.74? What are the versions, please? |
Available in 0.73.7+ |
Quick Fix; |
Description
When the scrollview container is bigger than total item width, on scroll the items start sticking on right on android.
Tested on physical device as well
Screen.Recording.2024-02-05.at.8.20.01.PM.mov
Steps to reproduce
Installed React Native macOs, android simulator
Write this code
<ScrollView horizontal={true} style={{backgroundColor: 'green'}}> <View style={{ height: 40, width: 50, marginRight: 20, backgroundColor: 'red', }} /> <View style={{ height: 40, width: 50, marginRight: 20, backgroundColor: 'red', }} /> </ScrollView>
Scroll horizontal to reproduce
React Native Version
0.73.3
Affected Platforms
Runtime - Android
Output of
npx react-native info
Stacktrace or Logs
Reproducer
snack.expo.dev/@uvrubel/rn-scrollview-horizontal
Screenshots and Videos
No response
The text was updated successfully, but these errors were encountered: