Skip to content

Commit 7a18d18

Browse files
author
Pavel Rotek
committed
fix velocity
1 parent 94969ed commit 7a18d18

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,15 @@ public void fling(int velocityY) {
314314
//
315315
// Hence, we can use the absolute value from whatever the OS gives
316316
// us and use the sign of what mOnScrollDispatchHelper has tracked.
317-
final int correctedVelocityY = (int)(Math.abs(velocityY) * Math.signum(mOnScrollDispatchHelper.getYFlingVelocity()));
317+
//final int correctedVelocityY = (int)(Math.abs(velocityY) * Math.signum(mOnScrollDispatchHelper.getYFlingVelocity()));
318318

319+
//BEGIN pavel.rotek wrong velocity on old phones
320+
float signum = Math.signum(mOnScrollDispatchHelper.getYFlingVelocity());
321+
if (signum == 0) {
322+
signum = Math.signum(velocityY);
323+
}
324+
final int correctedVelocityY = (int)(Math.abs(velocityY) * signum);
325+
//END
319326

320327
if (mPagingEnabled) {
321328
flingAndSnap(correctedVelocityY);

0 commit comments

Comments
 (0)