Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
[pagingscrollview] Don't inform the delegate of page changes when pag…
Browse files Browse the repository at this point in the history
…e changes have been explicitly requested.
  • Loading branch information
jverkoey committed Jul 31, 2012
1 parent 7be27dd commit 4211873
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/pagingscrollview/src/NIPagingScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ - (void)displayPageAtIndex:(NSInteger)pageIndex {


///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)updateVisiblePages {
- (void)updateVisiblePagesAnimated:(BOOL)animated {
NSRange visiblePageRange = [self visiblePageRange];

// Recycle no-longer-visible pages. We copy _visiblePages because we may modify it while we're
Expand Down Expand Up @@ -380,7 +380,7 @@ - (void)updateVisiblePages {
_centerPageIndex = -1;
}

if (oldCenterPageIndex != _centerPageIndex
if (!animated && oldCenterPageIndex != _centerPageIndex
&& [self.delegate respondsToSelector:@selector(pagingScrollViewDidChangePages:)]) {
[self.delegate pagingScrollViewDidChangePages:self];
}
Expand Down Expand Up @@ -437,7 +437,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (!_isModifyingContentOffset) {
// This method is called repeatedly as the user scrolls so updateVisiblePages must be
// light-weight enough not to noticeably impact performance.
[self updateVisiblePages];
[self updateVisiblePagesAnimated:NO];

if ([self.delegate respondsToSelector:@selector(pagingScrollViewDidScroll:)]) {
[self.delegate pagingScrollViewDidScroll:self];
Expand Down Expand Up @@ -583,7 +583,7 @@ - (void)reloadData {
}

// Begin requesting the page information from the data source.
[self updateVisiblePages];
[self updateVisiblePagesAnimated:NO];
}


Expand Down Expand Up @@ -656,7 +656,7 @@ - (void)didAnimateToPage:(NSNumber *)pageIndex {
self.pagingScrollView.contentOffset = offset;
_isModifyingContentOffset = NO;

[self updateVisiblePages];
[self updateVisiblePagesAnimated:YES];
}


Expand All @@ -677,7 +677,7 @@ - (BOOL)moveToPageAtIndex:(NSInteger)pageIndex animated:(BOOL)animated {
if (animated) {
_isAnimatingToPage = YES;
SEL selector = @selector(didAnimateToPage:);
[NSObject cancelPreviousPerformRequestsWithTarget: self];
[NSObject cancelPreviousPerformRequestsWithTarget:self];

// When the animation is finished we reset the content offset just in case the frame
// changes while we're animating (like when rotating the device). To do this we need
Expand Down

0 comments on commit 4211873

Please sign in to comment.