FSPagerView
FSPagerView copied to clipboard
Scroll to right on last item returns wrong index.
Good day. First of all. Thank you for this amazing lib. I've founded an issue. In horizontal scroll on last cell after one more swipe to right we are getting index 0.
Key settings:
pagerView.bounces = false let transformer = FSPagerViewTransformer(type: .linear) transformer.minimumAlpha = 1.0 pagerView.transformer = transformer pagerView.itemSize = CGSize(width: itemWidth, height: itemHeight) pagerView.interitemSpacing = interitemSpacing
I temporary fixed issue for myself. ` open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelegate { .....
public func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
if let function = self.delegate?.pagerViewWillEndDragging(_:targetIndex:) {
let contentOffset = self.scrollDirection == .horizontal ? targetContentOffset.pointee.x : targetContentOffset.pointee.y
let targetItem = lround(Double(contentOffset/self.collectionViewLayout.itemSpacing))
// --- HERE
if targetItem != self.numberOfItems {
function(self, targetItem % self.numberOfItems)
}
// --- HERE
}
if self.automaticSlidingInterval > 0 {
self.startTimer()
}
}
`
But anyway. Thank you so much for your job.
@show6time Thank You