4 Commits

Author SHA1 Message Date
hryk224 bcc954d105 Update podspec 2017-01-12 10:40:48 +09:00
hryk224 543b75cf56 Merge pull request #11 from jwardle/master
selectItem implementation
2017-01-12 10:38:49 +09:00
James Wardle 4bd0209ccb Update InfiniteCollectionView.swift
~ Enhanced the implementation to correct the index.
2017-01-10 21:59:52 +00:00
James Wardle 6fcd6a52e2 Update InfiniteCollectionView.swift
+ Added selectItem override to allow programatic selection of items - previously this was not considered and broken.
2017-01-09 22:01:02 +00:00
3 changed files with 24 additions and 2 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "InfiniteCollectionView"
s.version = "1.2.1"
s.version = "1.3.0"
s.summary = "Infinite Scrolling Using UICollectionView."
s.homepage = "https://github.com/hryk224/InfiniteCollectionView"
s.screenshots = "https://github.com/hryk224/InfiniteCollectionView/wiki/images/sample1.gif"
@@ -50,6 +50,28 @@ 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) {
// Correct the input IndexPath
let correctedIndexPath = IndexPath(row: correctedIndex(indexPath!.item + indexOffset), section: 0);
// Get the currently visible cell(s) - assumes a cell is visible
guard let visibleCell = self.visibleCells.first else{
return; // Nothing to select...
}
// Index path of the cell - does not consider multiple cells on the screen at the same time
var visibleIndexPath : IndexPath! = self.indexPath(for: visibleCell);
let testIndexPath = IndexPath(row: correctedIndex(visibleIndexPath!.item), section: 0);
guard correctedIndexPath != testIndexPath else{
return; // Do not re-select the same cell
}
// Call supercase to select the correct IndexPath
super.selectItem(at: correctedIndexPath, animated: animated, scrollPosition: scrollPosition);
}
}
// MARK: - private
+1 -1
View File
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.2.1</string>
<string>1.3.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>