Skip to content

Commit 59cf86c

Browse files
committed
Workaround a wrong fling direction if FlatList or VirtualizedList is inverted.
1 parent a3752c6 commit 59cf86c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,16 @@ public void getClippingRect(Rect outClippingRect) {
302302

303303
@Override
304304
public void fling(int velocityY) {
305+
// Workaround.
306+
// On Android P if a ScrollView is inverted, we will get a wrong sign for
307+
// velocityY (see https://issuetracker.google.com/issues/112385925).
308+
// At the same time, mOnScrollDispatchHelper tracks the correct velocity direction.
309+
//
310+
// Hence, we can use the absolute value from whatever the OS gives
311+
// us and use the sign of what mOnScrollDispatchHelper has tracked.
312+
velocityY = (int)(Math.abs(velocityY) * Math.signum(mOnScrollDispatchHelper.getYVelocity()));
313+
314+
305315
if (mPagingEnabled) {
306316
smoothScrollAndSnap(velocityY);
307317
} else if (mScroller != null) {

0 commit comments

Comments
 (0)