Skip to content

Commit

Permalink
swipe to only one item
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-satish-v committed Apr 30, 2018
1 parent f9c1774 commit e4f57fd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Sources/FSPageViewLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ class FSPagerViewLayout: UICollectionViewLayout {
offset += self.itemSpacing * (velocity.x)/abs(velocity.x)
}
}

let targetIndex = Int(offset/self.itemSpacing)
let originalIndex = Int(round(originalContentOffsetX/self.itemSpacing))
if targetIndex < originalIndex - 1 {
offset = CGFloat(originalIndex - 1)*self.itemSpacing
} else if targetIndex > originalIndex + 1 {
offset = CGFloat(originalIndex + 1)*self.itemSpacing
}
return offset
}()
let proposedContentOffsetY: CGFloat = {
Expand Down

0 comments on commit e4f57fd

Please sign in to comment.