Skip to content

Commit

Permalink
improve paging algorithm to account for zero velocity
Browse files Browse the repository at this point in the history
  • Loading branch information
JoniVR committed Aug 15, 2019
1 parent 48c7c02 commit 45a4c3b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/VerticalCardSwiperFlowLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ internal class VerticalCardSwiperFlowLayout: UICollectionViewFlowLayout {
let approximatePage = collectionView.contentOffset.y/pageHeight

// Determine the current page based on velocity.
let currentPage = (velocity.y < 0.0) ? floor(approximatePage) : ceil(approximatePage)
let currentPage = velocity.y == 0.0 ? round(approximatePage) : (velocity.y < 0.0 ? floor(approximatePage) : ceil(approximatePage))

// Create custom flickVelocity.
let flickVelocity = velocity.y * 0.3
Expand Down

0 comments on commit 45a4c3b

Please sign in to comment.