Update InfiniteCollectionView.swift

+ Added selectItem override to allow programatic selection of items - previously this was not considered and broken.
This commit is contained in:
James Wardle
2017-01-09 22:01:02 +00:00
committed by GitHub
parent d5afefb36d
commit 6fcd6a52e2
@@ -50,6 +50,10 @@ open class InfiniteCollectionView: UICollectionView {
open func rotate(_ notification: Notification) {
setContentOffset(CGPoint(x: CGFloat(pageIndex + indexOffset) * itemWidth, y: contentOffset.y), animated: false)
}
open override func selectItem(at indexPath: IndexPath?, animated: Bool, scrollPosition: UICollectionViewScrollPosition) {
let updatedIndexPath = IndexPath(row: correctedIndex(indexPath!.item + indexOffset), section: 0);
super.selectItem(at: updatedIndexPath, animated: animated, scrollPosition: scrollPosition);
}
}
// MARK: - private