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

Commit 61280d0

Browse files
author
Amir Khorsandi
committed
Invalidate layout on set current page without animation
1 parent 1317fc8 commit 61280d0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Lib/CollectionViewPagingLayout.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ public class CollectionViewPagingLayout: UICollectionViewLayout {
219219
}
220220
collectionView?.setContentOffset(contentOffset, animated: animated)
221221
CATransaction.commit()
222+
223+
// 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()
227+
})
228+
}
222229
}
223230

224231
private func addTapGestureToCollectionView() {

0 commit comments

Comments
 (0)