Skip to content

Commit

Permalink
Merge branch 'master' of github.com:RobotsAndPencils/RPSlidingMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Thorsteinson committed Apr 14, 2014
2 parents ca6be51 + 92e40f7 commit 75a42e3
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions RPSlidingMenu/RPSlidingMenuLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,13 @@ - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
return attributesInRect;
}

- (CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset withScrollingVelocity:(CGPoint)velocity {

// so when a person stops dragging/flicking - we use the drag interval to determine where it will snap to
CGFloat currentY = self.collectionView.contentOffset.y;
// the marker of the next drag/page intervals
CGFloat lastPageY = (NSInteger)(currentY / RPSlidingCellDragInterval) * RPSlidingCellDragInterval;
CGFloat nextPageY = lastPageY + RPSlidingCellDragInterval;

// snap to whichever is closest
if (velocity.y > 0) {
return CGPointMake(self.collectionView.contentOffset.x, nextPageY);
} else {
return CGPointMake(self.collectionView.contentOffset.x, lastPageY);
}
- (CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset withScrollingVelocity:(CGPoint)velocity {

CGFloat proposedPageIndex = roundf(proposedContentOffset.y / RPSlidingCellDragInterval);
CGFloat nearestPageOffset = proposedPageIndex * RPSlidingCellDragInterval;

return CGPointMake(0.0f, nearestPageOffset);
}

- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath {
Expand Down

0 comments on commit 75a42e3

Please sign in to comment.