airbnb / MagazineLayout

A collection view layout capable of laying out views in vertically scrolling grids and lists.
Apache License 2.0
3.3k stars 219 forks source link

fix content offset adjustment for bounds changing #130

Closed jinxiao-zang closed 5 months ago

jinxiao-zang commented 5 months ago

Details

For the bottomToTop layout, the y offset adjustment max(currentCollectionView.bounds.height - newBounds.height + contentInset.bottom, 0) is not right. we should not involve the contentInset.bottom. The iOS system will help adjust the yOffset when new bounds exceed the boundary. It means we should check if newBounds.maxY < currentCollectionView.contentSize.height + contentInset.bottom as well.

Motivation and Context

We are building an messaging screen for Airbnb and I find this issue causes the message cells jumping when typing indicator hide and show.

How Has This Been Tested

I built a small sample to test this case. Before this change: The cells move up every time the bounds changed. After the change: The cells keep bottom spacing the same.

Before After
ezgif-1-b9833aa1ea ezgif-1-99777f3cb7

Types of changes

Checklist

jinxiao-zang commented 5 months ago

@brynbodayle @bryankeller PTAL!

bryankeller commented 5 months ago

Thanks @jinxiao-zang !