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
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: 14987beac931e3d47a4cc013f5d2a4ccb5c2b8bd
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java
+7-2Lines changed: 7 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -849,8 +849,13 @@ public boolean dispatchGenericMotionEvent(MotionEvent ev) {
849
849
@Override
850
850
publicvoidrun() {
851
851
mPostTouchRunnable = null;
852
-
// Trigger snap alignment now that scrolling has stopped
853
-
handlePostTouchScrolling(0, 0);
852
+
// +1/-1 velocity if scrolling right or left. This is to ensure that the
853
+
// next/previous page is picked rather than sliding backwards to the current page
0 commit comments