fix(inverted): force firstItemOffset to 0 for inverted lists#2300
Open
VickyStash wants to merge 1 commit into
Open
fix(inverted): force firstItemOffset to 0 for inverted lists#2300VickyStash wants to merge 1 commit into
firstItemOffset to 0 for inverted lists#2300VickyStash wants to merge 1 commit into
Conversation
Author
|
@naqvitalha Please take a look! |
firstItemOffset to 0 for inverted listsfirstItemOffset to 0 for inverted lists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Problem
Inverted FlashList only renders a few items, leaving the rest of the viewport as white space while scrolling.
RecyclerViewmeasuresfirstItemOffsetby callingmeasureFirstChildLayoutrelative to the outer container. When inverted is true, the outer container has ascaleY: -1transform applied, which flips the coordinate system. As a result, the measured y-offset comes back equal to the container height instead of 0.That bad offset propagates through
adjustedOffset = scrollOffset - firstItemOffset, pushing every adjusted scroll position into negative space where no items live.Only the handful of items caught by the draw-distance buffer ever render — everything else stays blank.
Reproduction stack: https://snack.expo.dev/@vikstash/inverted-flashlist-bug
Steps:
invertedlist with 50 items.Bug video:
fl-bug.mp4
Solution
Force
firstItemOffsetto 0 when inverted is true. ThescaleY: -1transform already handles the visual inversion, so the raw offset measured against the flipped coordinate system isn't needed (and is actively wrong).Reviewers’ hat-rack 🎩