Skip to content

Commit

Permalink
Android ScrollView fix for snapToInterval not snapping to end
Browse files Browse the repository at this point in the history
Summary:
The end-of-scrollable-range offset was not clipped before the nearestOffset calculation causing the ScrollView to not snap to the end of the view when the width of the ScrollView was not an exact multiple of snapToInterval.

Addresses #21116 (comment)

Reviewed By: yungsters

Differential Revision: D10248545

fbshipit-source-id: 2bdc94ea0a9d9f063769f2c5da4c33d4872b1db2
  • Loading branch information
olegbl authored and facebook-github-bot committed Oct 11, 2018
1 parent 83da74b commit 6eeff75
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ private void flingAndSnap(int velocityX) {
double interval = (double) getSnapInterval();
double ratio = (double) targetOffset / interval;
smallerOffset = (int) (Math.floor(ratio) * interval);
largerOffset = (int) (Math.ceil(ratio) * interval);
largerOffset = Math.min((int) (Math.ceil(ratio) * interval), maximumOffset);
}

// Calculate the nearest offset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ private void flingAndSnap(int velocityY) {
double interval = (double) getSnapInterval();
double ratio = (double) targetOffset / interval;
smallerOffset = (int) (Math.floor(ratio) * interval);
largerOffset = (int) (Math.ceil(ratio) * interval);
largerOffset = Math.min((int) (Math.ceil(ratio) * interval), maximumOffset);
}

// Calculate the nearest offset
Expand Down

0 comments on commit 6eeff75

Please sign in to comment.