Skip to content

Commit 1acc1b3

Browse files
Using performBatchUpdates instead of layoutIfNeeded.
1 parent f865418 commit 1acc1b3

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

ListableUI/Sources/ListView/ListView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ public final class ListView : UIView
12911291
if let destination = info.destination.destination(with: self.content) {
12921292

12931293
if behavior.verticalLayoutGravity == .bottom {
1294-
/// Perform a layout to adjust the `contentSize` of the collection view before
1294+
/// Perform an update to adjust the `contentSize` of the collection view before
12951295
/// scrolling. This avoids an issue where:
12961296
/// - the list is first appearing with `VerticalLayoutGravity.bottom` and
12971297
/// `AutoScrollAction` behaviors
@@ -1303,7 +1303,7 @@ public final class ListView : UIView
13031303
/// asynchronously update the underlying `contentSize` as part of the initial layout,
13041304
/// moments after this method is executed. The list's `contentSize` is overridden to
13051305
/// keep the offset anchored to the bottom when using `VerticalLayoutGravity.bottom`.
1306-
collectionView.layoutIfNeeded()
1306+
collectionView.performBatchUpdates(nil)
13071307
}
13081308

13091309
guard self.scrollTo(item: destination, position: info.position, animated: animated) else { return }
@@ -1312,11 +1312,11 @@ public final class ListView : UIView
13121312
info.didPerform(state.positionInfo)
13131313
}
13141314
} else {
1315-
/// Perform a layout after an animationless scroll so that `CollectionViewLayout`'s
1315+
/// Perform an update after an animationless scroll so that `CollectionViewLayout`'s
13161316
/// `prepare()` function will synchronously execute before calling `didPerform`. Otherwise,
13171317
/// the list's `visibleContent` and the resulting `scrollPositionInfo.visibleItems` will
13181318
/// be stale.
1319-
collectionView.layoutIfNeeded()
1319+
collectionView.performBatchUpdates(nil)
13201320
info.didPerform(scrollPositionInfo)
13211321
}
13221322
}

0 commit comments

Comments
 (0)