FSPagerView icon indicating copy to clipboard operation
FSPagerView copied to clipboard

Scroll to right on last item returns wrong index.

Open show6time opened this issue 2 years ago • 1 comments

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 avatar Nov 06 '21 13:11 show6time

@show6time Thank You

look27 avatar Mar 26 '24 06:03 look27