feat: [ScrollView,FlatList] Add ref.scrollToStart({animated?: boolean}) method#45202
feat: [ScrollView,FlatList] Add ref.scrollToStart({animated?: boolean}) method#45202retyui wants to merge 1 commit into
ref.scrollToStart({animated?: boolean}) method#45202Conversation
e5f52f3 to
88aa470
Compare
88aa470 to
8a8e141
Compare
|
This seems like a sane addition, but current implementation is not correct for horizontal lists in RTL. |
Let me create a demo and test it https://reactnative.dev/blog/2016/08/19/right-to-left-support-for-react-native-apps#making-an-app-rtl-ready |
|
The RNTester FlatList example has a checkbox for RTL which will apply forceRTL. That is what I usually use. But, the gist is that, as of recent versions, all the events and commands are aligned so that x coordinate space is not inverted. This can be a bit tricky, since as more content is added to the list, the x coordinate will change alongside.
|
|
|
||
| scrollToStart(params?: ?{animated?: ?boolean, ...}) { | ||
| const animated = params ? params.animated : true; | ||
| this.scrollToOffset({animated, offset: 0}); |
There was a problem hiding this comment.
how does this behave if ScrollView has insets?
Summary:
scrollToEnd(options?: {animated?: boolean})is available out of the box, and it's surprising thatscrollToStartwasn't added yetChangelog:
[GENERAL] [ADDED] - [ScrollView, FlatList] Add
ref.scrollToStart({animated?: boolean})methodTest Plan:
Manual + types tests
Screen.Recording.2024-06-27.at.12.27.29.mov
Screen.Recording.2024-06-27.at.12.23.52.mov