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

Commit 2e7daac

Browse files
committed
Avoid divide by zero
1 parent 52e504b commit 2e7daac

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Lib/CollectionViewPagingLayout.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ public class CollectionViewPagingLayout: UICollectionViewLayout {
131131
let contentOffset = scrollDirection == .horizontal ?
132132
(collectionView.contentOffset.x + collectionView.contentInset.left) :
133133
(collectionView.contentOffset.y + collectionView.contentInset.top)
134-
currentPage = Int(round(contentOffset / pageSize))
134+
if pageSize > 0 {
135+
currentPage = Int(round(contentOffset / pageSize))
136+
}
135137
}
136138
if currentPage != self.currentPage {
137139
self.currentPage = currentPage

0 commit comments

Comments
 (0)