Skip to content

Commit

Permalink
Merge pull request #50 from CVertex/master
Browse files Browse the repository at this point in the history
Add callbacks for willScrollPreviousPage and willScrollNextPage
  • Loading branch information
gblancogarcia committed Aug 31, 2015
2 parents 05d2d90 + c219930 commit a08d799
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
21 changes: 21 additions & 0 deletions GBInfiniteScrollView/GBInfiniteScrollView/GBInfiniteScrollView.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,17 @@ typedef NS_ENUM(NSInteger, GBScrollDirection) {

-(void)infiniteScrollViewDidPan:(UIPanGestureRecognizer*)pan;


/**
* Called when the GBInfiniteScrollView will scroll to next page.
*
* @warning Optional
*
* @param infiniteScrollView The infinite scroll view object.
*/
- (void)infiniteScrollViewWillScrollNextPage:(GBInfiniteScrollView *)infiniteScrollView;


/**
* Called when the GBInfiniteScrollView has scrolled to next page.
*
Expand All @@ -275,6 +286,16 @@ typedef NS_ENUM(NSInteger, GBScrollDirection) {
*/
- (void)infiniteScrollViewDidScrollNextPage:(GBInfiniteScrollView *)infiniteScrollView;


/**
* Called when the GBInfiniteScrollView will scroll to previous page.
*
* @warning Optional
*
* @param infiniteScrollView The infinite scroll view object.
*/
- (void)infiniteScrollViewWillScrollPreviousPage:(GBInfiniteScrollView *)infiniteScrollView;

/**
* Called when the GBInfiniteScrollView has scrolled to previous page.
*
Expand Down
11 changes: 11 additions & 0 deletions GBInfiniteScrollView/GBInfiniteScrollView/GBInfiniteScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,11 @@ - (void)scrollToNextPage
y = CGRectGetMaxY(frame);
}

// Notify delegate we're going to the next page
if ([self.infiniteScrollViewDelegate respondsToSelector:@selector(infiniteScrollViewWillScrollNextPage:)]) {
[self.infiniteScrollViewDelegate infiniteScrollViewWillScrollNextPage:self];
}

CGPoint point = CGPointMake(x, y);
[self setContentOffsetWithCustomDuration:point];
}
Expand All @@ -1700,6 +1705,12 @@ - (void)scrollToPreviousPage
y = CGRectGetMinY(frame) - [self pageHeight];
}


// Notify delegate we're going to the next page
if ([self.infiniteScrollViewDelegate respondsToSelector:@selector(infiniteScrollViewWillScrollPreviousPage:)]) {
[self.infiniteScrollViewDelegate infiniteScrollViewWillScrollPreviousPage:self];
}

CGPoint point = CGPointMake(x, y);
[self setContentOffsetWithCustomDuration:point];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,13 +633,25 @@ - (void)stopAutoScroll
self.autoScroll = NO;
}

- (void)infiniteScrollViewWillScrollNextPage:(GBInfiniteScrollView *)infiniteScrollView {
if (self.debug) {
NSLog(@"Will scroll next page");
}
}

- (void)infiniteScrollViewDidScrollNextPage:(GBInfiniteScrollView *)infiniteScrollView
{
if (self.debug) {
NSLog(@"Did scroll next page");
}
}

- (void)infiniteScrollViewWillScrollPreviousPage:(GBInfiniteScrollView *)infiniteScrollView {
if (self.debug) {
NSLog(@"Will scroll previous page");
}
}

- (void)infiniteScrollViewDidScrollPreviousPage:(GBInfiniteScrollView *)infiniteScrollView
{
if (self.debug) {
Expand Down

0 comments on commit a08d799

Please sign in to comment.