Skip to content

Commit d3a04b7

Browse files
committed
calculated scrollable range and bounds to prevent overscroll
1 parent 1a6d466 commit d3a04b7

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,11 @@ private void recreateFlingAnimation(int scrollY) {
12301230
float direction = Math.signum(mScroller.getFinalY() - mScroller.getStartY());
12311231
float flingVelocityY = mScroller.getCurrVelocity() * direction;
12321232

1233-
mScroller.fling(getScrollX(), scrollY, 0, (int) flingVelocityY, 0, 0, 0, Integer.MAX_VALUE);
1233+
// Proposed fix to handle overscroll
1234+
int maxScrollY = computeVerticalScrollRange() - getHeight(); // Calculate the actual scrollable range
1235+
maxScrollY = Math.max(0, maxScrollY); // Calculate the max bound to prevent negative bounds
1236+
1237+
mScroller.fling(getScrollX(), scrollY, 0, (int) flingVelocityY, 0, 0, 0, maxScrollY);
12341238
} else {
12351239
scrollTo(getScrollX(), scrollY + (mScroller.getCurrX() - scrollerYBeforeTick));
12361240
}

0 commit comments

Comments
 (0)