-
Notifications
You must be signed in to change notification settings - Fork 220
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
Bk/fix initial attributes target content offset #124
Bk/fix initial attributes target content offset #124
Conversation
26ed39b
to
fffd98d
Compare
@@ -132,7 +132,7 @@ public enum MagazineLayoutItemHeightMode: Hashable { | |||
/// For example, if you support multiline labels or dynamic type, your height is likely not known | |||
/// until the Auto Layout engine resolves the layout at runtime. | |||
public static var dynamic: MagazineLayoutItemHeightMode { | |||
.dynamic(estimatedHeight: MagazineLayout.Default.ItemHeight) | |||
.dynamic(estimatedHeight: 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to do some testing to make sure this doesn't break anything in the Airbnb app
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, not sure about this. I think a lower estimated height could be mean more cells are initially loaded, it's a less accurate estimation. So we could be receiving worse performance to address the animation edge case.
Does the issue only occur if the estimated height puts the original layout attributes frame intersecting the top of the collection view?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are good points - I'll do some more investigation
@@ -132,7 +132,7 @@ public enum MagazineLayoutItemHeightMode: Hashable { | |||
/// For example, if you support multiline labels or dynamic type, your height is likely not known | |||
/// until the Auto Layout engine resolves the layout at runtime. | |||
public static var dynamic: MagazineLayoutItemHeightMode { | |||
.dynamic(estimatedHeight: MagazineLayout.Default.ItemHeight) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See we still use this constant elsewhere, should we change the constant value instead? A bit confused on when we want this smaller height versus not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized we were using this default item height for not just the estimated height, but also the default static height if someone doesn't implement sizeModeForItemAt
. Didn't want to cause a regression in that case.
c991247
to
99f7e84
Compare
99f7e84
to
2d10f09
Compare
Details
This PR fixes 1 issue (can't find a fix for the other, sadly):
Before:
p1before.mp4
After:
p1after.mp4
MagazineLayout
's fault. It happens when the inserted item / moved item is close to the the top of the screen, which makes me think internally,UICollectionView
thinks the moving item isn't visible, and therefore short-circuits its rendering. Interestingly, reducing the estimated item height from150
->10
fixes it. 150 was a magic number, and 10 is too, but I think using a smaller number makes it less likely for collection view to hit this issue.Before:
p2before.mp4
Related Issue
N/A
Motivation and Context
Bug fixes
How Has This Been Tested
Types of changes
Checklist