Skip to content

Commit 6fcd6a5

Browse files
authored
Update InfiniteCollectionView.swift
+ Added selectItem override to allow programatic selection of items - previously this was not considered and broken.
1 parent d5afefb commit 6fcd6a5

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

InfiniteCollectionView/InfiniteCollectionView.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ open class InfiniteCollectionView: UICollectionView {
5050
open func rotate(_ notification: Notification) {
5151
setContentOffset(CGPoint(x: CGFloat(pageIndex + indexOffset) * itemWidth, y: contentOffset.y), animated: false)
5252
}
53+
open override func selectItem(at indexPath: IndexPath?, animated: Bool, scrollPosition: UICollectionViewScrollPosition) {
54+
let updatedIndexPath = IndexPath(row: correctedIndex(indexPath!.item + indexOffset), section: 0);
55+
super.selectItem(at: updatedIndexPath, animated: animated, scrollPosition: scrollPosition);
56+
}
5357
}
5458

5559
// MARK: - private

0 commit comments

Comments
 (0)