Skip to content

Commit e158406

Browse files
authored
Improve target content offset calculation (#139)
1 parent aad5bd2 commit e158406

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

MagazineLayout/Public/MagazineLayout.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,8 @@ public final class MagazineLayout: UICollectionViewLayout {
12981298
// When scrolling up, only calculate a target content offset based on visible, already-sized
12991299
// cells. Otherwise, scrolling will be jumpy.
13001300
modelState.isItemHeightSettled(indexPath: $0.elementLocation.indexPath)
1301-
}
1301+
} ?? visibleItemLocationFramePairs.first // fallback to the first item if we can't find one with a settled height
1302+
13021303
let lastVisibleItemLocationFramePair = visibleItemLocationFramePairs.last
13031304

13041305
guard

0 commit comments

Comments
 (0)