Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine top and bottom item anchor calculation #129

Merged
merged 2 commits into from
May 2, 2024

Conversation

bryankeller
Copy link
Contributor

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

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@bryankeller bryankeller added the bug Something isn't working label May 2, 2024
brynbodayle
brynbodayle previously approved these changes May 2, 2024
Copy link

@brynbodayle brynbodayle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, makes a ton of sense!

@bryankeller bryankeller force-pushed the bk/refine-target-content-offset branch from dee0bbd to 6e2f69f Compare May 2, 2024 20:50
@bryankeller bryankeller merged commit 7655494 into master May 2, 2024
1 check passed
@bryankeller bryankeller deleted the bk/refine-target-content-offset branch May 2, 2024 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants