Skip to content

Commit

Permalink
fix content offset adjustment for bounds changing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinxiao Zang committed May 23, 2024
1 parent 7655494 commit 0aa06d4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions MagazineLayout/Public/MagazineLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -615,10 +615,13 @@ public final class MagazineLayout: UICollectionViewLayout {

// If our layout direction is bottom to top we want to adjust scroll position relative to the
// bottom
if case .bottomToTop = verticalLayoutDirection {
if
case .bottomToTop = verticalLayoutDirection,
newBounds.maxY < currentCollectionView.contentSize.height + contentInset.bottom
{
invalidationContext.contentOffsetAdjustment = CGPoint(
x: 0.0,
y: max(currentCollectionView.bounds.height - newBounds.height + contentInset.bottom, 0))
y: currentCollectionView.bounds.maxY - newBounds.maxY)
}

return invalidationContext
Expand Down

0 comments on commit 0aa06d4

Please sign in to comment.