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

Commit a1e1b17

Browse files
committed
Remove unnecessary flag ignoreUpdateCurrentPage
1 parent df67411 commit a1e1b17

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

Lib/CollectionViewPagingLayout.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public class CollectionViewPagingLayout: UICollectionViewLayout {
6565

6666

6767
// MARK: UICollectionViewLayout
68-
var ignoreUpdateCurrentPage : Bool = false
6968

7069
override public func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool {
7170
true
@@ -130,9 +129,7 @@ public class CollectionViewPagingLayout: UICollectionViewLayout {
130129

131130
override public func invalidateLayout() {
132131
super.invalidateLayout()
133-
if !ignoreUpdateCurrentPage{
134-
updateCurrentPageIfNeeded()
135-
}
132+
updateCurrentPageIfNeeded()
136133
}
137134

138135

@@ -177,14 +174,14 @@ public class CollectionViewPagingLayout: UICollectionViewLayout {
177174
offset = max(0, offset)
178175
offset = min(offset, maxPossibleOffset)
179176
let contentOffset: CGPoint = scrollDirection == .horizontal ? CGPoint(x: offset, y: 0) : CGPoint(x: 0, y: offset)
180-
ignoreUpdateCurrentPage = true
181177
CATransaction.begin()
182-
CATransaction.setCompletionBlock({
183-
self.ignoreUpdateCurrentPage = false
184-
self.updateCurrentPageIfNeeded(basedOn: contentOffset)
185-
})
178+
CATransaction.setCompletionBlock { [weak self] in
179+
self?.updateCurrentPageIfNeeded(basedOn: contentOffset)
180+
}
181+
if !animated {
182+
updateCurrentPageIfNeeded(basedOn: contentOffset)
183+
}
186184
collectionView?.setContentOffset(contentOffset, animated: animated)
187185
CATransaction.commit()
188-
189186
}
190187
}

0 commit comments

Comments
 (0)