Commit 963f7a5
Maintain momentum through non-zero velocity when paging is enabled (#54413)
Summary:
Pull Request resolved: #54413
We should treat `ACTION_SCROLL` events akin to momentum scrolling--they represent a scroll with non-zero velocity--but not as momentum events themselves--they don't have a real velocity after they've dispatched. When paging is enabled, we should run the same `flingAndSnap` logic and rely on this non-zero velocity to encourage scrolling to the next item in the direction of the scroll rather than immediately picking the nearest offset.
The end effect of this change is that scrolling down will always go to the next item regardless of when scrolling stops. Scrolling up will always go to the previous item. Similar for horizontal scrolling per right/left scrolling.
Changelog: [Internal]
Reviewed By: necolas
Differential Revision: D86151012
fbshipit-source-id: 14987beac931e3d47a4cc013f5d2a4ccb5c2b8bd1 parent 3012aac commit 963f7a5
2 files changed
Lines changed: 14 additions & 4 deletions
File tree
- packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
849 | 849 | | |
850 | 850 | | |
851 | 851 | | |
852 | | - | |
853 | | - | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
854 | 859 | | |
855 | 860 | | |
856 | 861 | | |
| |||
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
688 | 688 | | |
689 | 689 | | |
690 | 690 | | |
691 | | - | |
692 | | - | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
693 | 698 | | |
694 | 699 | | |
695 | 700 | | |
| |||
0 commit comments