Skip to content

Commit

Permalink
Fix #flingAndSnap to check all the scroll item for offset range
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ryancat authored and facebook-github-bot committed Oct 27, 2021
1 parent 25605fb commit 61e1b6f
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 @@ -983,7 +983,7 @@ private void flingAndSnap(int velocityX) {
maximumOffset);
} else {
ViewGroup contentView = (ViewGroup) getContentView();
for (int i = 1; i < contentView.getChildCount(); i++) {
for (int i = 0; i < contentView.getChildCount(); i++) {
View item = contentView.getChildAt(i);
int itemStartOffset =
getItemStartOffset(mSnapToAlignment, item.getLeft(), item.getWidth(), width);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ private void flingAndSnap(int velocityY) {
maximumOffset);
} else {
ViewGroup contentView = (ViewGroup) getContentView();
for (int i = 1; i < contentView.getChildCount(); i++) {
for (int i = 0; i < contentView.getChildCount(); i++) {
View item = contentView.getChildAt(i);
int itemStartOffset;
switch (mSnapToAlignment) {
Expand Down

0 comments on commit 61e1b6f

Please sign in to comment.