Skip to content

Commit

Permalink
fix: fix jerk effect zepojo#37
Browse files Browse the repository at this point in the history
  • Loading branch information
yyjim committed Nov 10, 2022
1 parent b1a3631 commit df0ded5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions UPCarouselFlowLayout/UPCarouselFlowLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ open class UPCarouselFlowLayout: UICollectionViewFlowLayout {
let isHorizontal = (self.scrollDirection == .horizontal)

let midSide = (isHorizontal ? collectionView.bounds.size.width : collectionView.bounds.size.height) / 2
let proposedContentOffsetCenterOrigin = (isHorizontal ? proposedContentOffset.x : proposedContentOffset.y) + midSide

let proposedContentOffsetCenterOrigin = (isHorizontal ? proposedContentOffset.x + 1000 * velocity.x : proposedContentOffset.y + 1000 * velocity.y) + midSide


var targetContentOffset: CGPoint
if isHorizontal {
let closest = layoutAttributes.sorted { abs($0.center.x - proposedContentOffsetCenterOrigin) < abs($1.center.x - proposedContentOffsetCenterOrigin) }.first ?? UICollectionViewLayoutAttributes()
Expand Down

0 comments on commit df0ded5

Please sign in to comment.