From 23be29b3a133ffa478d3155f9afb25eb3271a812 Mon Sep 17 00:00:00 2001 From: WenchaoD Date: Tue, 20 Jun 2017 23:21:57 +0800 Subject: [PATCH] Fix issue #46 --- Sources/FSPageViewLayout.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/FSPageViewLayout.swift b/Sources/FSPageViewLayout.swift index fb388a5..b59d4b9 100644 --- a/Sources/FSPageViewLayout.swift +++ b/Sources/FSPageViewLayout.swift @@ -128,7 +128,8 @@ class FSPagerViewLayout: UICollectionViewLayout { var origin = startPosition let maxPosition = self.scrollDirection == .horizontal ? min(rect.maxX,self.contentSize.width-self.actualItemSize.width-self.leadingSpacing) : min(rect.maxY,self.contentSize.height-self.actualItemSize.height-self.leadingSpacing) - while origin <= maxPosition { + // https://stackoverflow.com/a/10335601/2398107 + while origin-maxPosition <= max(CGFloat(100.0) * .ulpOfOne * fabs(origin+maxPosition), .leastNonzeroMagnitude) { let indexPath = IndexPath(item: itemIndex%self.numberOfItems, section: itemIndex/self.numberOfItems) let attributes = self.layoutAttributesForItem(at: indexPath) as! FSPagerViewLayoutAttributes self.applyTransform(to: attributes, with: self.pagerView?.transformer)