Skip to content

Commit

Permalink
Fix issue with transition distance
Browse files Browse the repository at this point in the history
The fix for the transition distance in #33 had an issue with selecting
an item on the opposite side while being near an edge. We only want to
subtract the overshoot when we’re moving towards an edge.
  • Loading branch information
rechsteiner committed Feb 20, 2017
1 parent d187795 commit 40ea307
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Parchment/Classes/PagingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,9 @@ open class PagingViewController<T: PagingItem>:
let upcomingCell = collectionView(collectionView, cellForItemAt: upcomingIndexPath)
var distance = self.distance(from: currentCell, to: upcomingCell)

if collectionView.near(edge: .left, clearance: -distance) {
if collectionView.near(edge: .left, clearance: -distance) && distance < 0 {
distance = -(collectionView.contentOffset.x + collectionView.contentInset.left)
} else if collectionView.near(edge: .right, clearance: distance) {
} else if collectionView.near(edge: .right, clearance: distance) && distance > 0 {
distance = collectionView.contentSize.width - (collectionView.contentOffset.x + collectionView.bounds.width)
}

Expand Down

0 comments on commit 40ea307

Please sign in to comment.