mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-15 23:03:58 +08:00
Android ScrollView fix for snapToInterval not snapping to end
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 https://github.com/facebook/react-native/issues/21116#issuecomment-427944838 Reviewed By: yungsters Differential Revision: D10248545 fbshipit-source-id: 2bdc94ea0a9d9f063769f2c5da4c33d4872b1db2
This commit is contained in:
committed by
Facebook Github Bot
parent
83da74b556
commit
6eeff75849
@@ -608,7 +608,7 @@ public class ReactHorizontalScrollView extends HorizontalScrollView implements
|
||||
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
|
||||
|
||||
@@ -569,7 +569,7 @@ public class ReactScrollView extends ScrollView implements ReactClippingViewGrou
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user