Refine top and bottom item anchor calculation #129
Merged
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.
Details
This refines our target content offset logic. Previously, we used the closest edge of an item to be an anchor. For example, in a
topToBottom
layout, we would use the topmost item's top or bottom edge as the anchor for scroll position preservation, depending on which was closest to the top edge. This causes weird issues if the height of an item changes, since it will visually grow upward or downward depending on how close it is to the top of the screen.I think a simpler and more predictable behavior is to simply always use the top edge of the topmost item as the anchor point. Similarly, for a
bottomToTop
layout, we'll always use the bottom edge of the bottommost item as the anchor point.Related Issue
N/A
Motivation and Context
Some weird issues with voting on wish lists, since adding a vote changes the height of the cell. The direction the card grows after resizing changes depending on how close it is to the top edge.
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-05-01.at.17.24.39.mp4
How Has This Been Tested
Types of changes
Checklist