Skip to content

Commit

Permalink
Merge pull request jverkoey#281 from dataway/HEAD
Browse files Browse the repository at this point in the history
[NIPagingScrollView] make moveToPageAtIndex not discard requested pageIndex
  • Loading branch information
jverkoey committed Sep 20, 2012
2 parents a24f72c + eec56ad commit 1b50f35
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/pagingscrollview/src/NIPagingScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ @interface NIPagingScrollView() {
BOOL _isModifyingContentOffset;
BOOL _isAnimatingToPage;
BOOL _isKillingAnimation;
NSInteger _animatingToPageIndex;
}

@property (nonatomic, retain) UIScrollView* pagingScrollView;
Expand Down Expand Up @@ -663,6 +664,10 @@ - (BOOL)hasPrevious {
///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)didAnimateToPage:(NSNumber *)pageIndex {
_isAnimatingToPage = NO;
if (_animatingToPageIndex != -1 && _animatingToPageIndex != [pageIndex integerValue]) {
[self moveToPageAtIndex:_animatingToPageIndex animated:YES];
return;
}

// Reset the content offset once the animation completes, just to be sure that the
// viewer sits on a page bounds even if we rotate the device while animating.
Expand All @@ -681,8 +686,10 @@ - (void)didAnimateToPage:(NSNumber *)pageIndex {
- (BOOL)moveToPageAtIndex:(NSInteger)pageIndex animated:(BOOL)animated {
if (_isAnimatingToPage) {
// Don't allow re-entry for sliding animations.
_animatingToPageIndex = pageIndex;
return NO;
}
_animatingToPageIndex = -1;

CGPoint offset = [self frameForPageAtIndex:pageIndex].origin;
offset = [self adjustOffsetWithMargin:offset];
Expand Down

0 comments on commit 1b50f35

Please sign in to comment.