Skip to content
This repository was archived by the owner on Jun 17, 2023. It is now read-only.

Commit cfcf95a

Browse files
author
Amir Khorsandi
committed
Fix infinite loop
1 parent a6714e8 commit cfcf95a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Lib/CollectionViewPagingLayout.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ public class CollectionViewPagingLayout: UICollectionViewLayout {
221221
CATransaction.commit()
222222

223223
// this is necessary when we want to set the current page without animation
224-
if !animated {
225-
collectionView?.performBatchUpdates({ [weak self] in
226-
self?.collectionView?.collectionViewLayout.invalidateLayout()
224+
if !animated, page != currentPage, let collectionView = collectionView {
225+
collectionView.performBatchUpdates({
226+
collectionView.collectionViewLayout.invalidateLayout()
227227
})
228228
}
229229
}

0 commit comments

Comments
 (0)