Skip to content

Commit 61e1b6f

Browse files
ryancatfacebook-github-bot
authored andcommitted
Fix #flingAndSnap to check all the scroll item for offset range
Summary: When calculating the offset range, we assume the first item is always at offset zero position and skipped that (as the smallerOffset is zero). However, this may not be the case in some situations. This diff changes the range measuring loop to always start from the first item. Changelog: [Android][Fixed] - Do NOT skip the first child view in the scroll view group when measuring the lower and upper bounds for snapping. Reviewed By: mdvacca Differential Revision: D31887086 fbshipit-source-id: af7221a621b2719d057afa6b64aa91c94ac01295
1 parent 25605fb commit 61e1b6f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ private void flingAndSnap(int velocityX) {
983983
maximumOffset);
984984
} else {
985985
ViewGroup contentView = (ViewGroup) getContentView();
986-
for (int i = 1; i < contentView.getChildCount(); i++) {
986+
for (int i = 0; i < contentView.getChildCount(); i++) {
987987
View item = contentView.getChildAt(i);
988988
int itemStartOffset =
989989
getItemStartOffset(mSnapToAlignment, item.getLeft(), item.getWidth(), width);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ private void flingAndSnap(int velocityY) {
766766
maximumOffset);
767767
} else {
768768
ViewGroup contentView = (ViewGroup) getContentView();
769-
for (int i = 1; i < contentView.getChildCount(); i++) {
769+
for (int i = 0; i < contentView.getChildCount(); i++) {
770770
View item = contentView.getChildAt(i);
771771
int itemStartOffset;
772772
switch (mSnapToAlignment) {

0 commit comments

Comments
 (0)