Small fix

This commit is contained in:
丁文超 2017-09-12 11:25:11 +08:00
parent cbf1b4b200
commit 19f230333d
1 changed files with 3 additions and 5 deletions

View File

@ -243,7 +243,7 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega
}
fileprivate var possibleTargetingIndexPath: IndexPath?
// MARK: - Overriden functions
@ -500,7 +500,7 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega
}
return indexPath
}
return self.isInfinite ? self.nearbyIndexPath(for: index) : IndexPath(item: index, section: 0)
return self.numberOfSections > 1 ? self.nearbyIndexPath(for: index) : IndexPath(item: index, section: 0)
}()
let contentOffset = self.collectionViewLayout.contentOffset(for: indexPath)
self.collectionView.setContentOffset(contentOffset, animated: animated)
@ -555,7 +555,7 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega
}
let contentOffset: CGPoint = {
let indexPath = self.centermostIndexPath
let section = self.isInfinite ? (indexPath.section+(indexPath.item+1)/self.numberOfItems) : 0
let section = self.numberOfSections > 1 ? (indexPath.section+(indexPath.item+1)/self.numberOfItems) : 0
let item = (indexPath.item+1) % self.numberOfItems
return self.collectionViewLayout.contentOffset(for: IndexPath(item: item, section: section))
}()
@ -584,5 +584,3 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega
}
}