Add scroll to page helper to ASPagerNode

This commit is contained in:
Levi McCallum
2015-12-21 09:07:48 -06:00
parent ad4db73b95
commit 10030dfe70
2 changed files with 10 additions and 0 deletions

View File

@@ -14,6 +14,8 @@
@property (weak, nonatomic) id<ASPagerNodeDataSource> dataSource; @property (weak, nonatomic) id<ASPagerNodeDataSource> dataSource;
- (void)scrollToPageAtIndex:(NSInteger)index animated:(BOOL)animated;
@end @end
@protocol ASPagerNodeDataSource <NSObject> @protocol ASPagerNodeDataSource <NSObject>

View File

@@ -49,6 +49,14 @@
[self setTuningParameters:renderParams forRangeType:ASLayoutRangeTypeRender]; [self setTuningParameters:renderParams forRangeType:ASLayoutRangeTypeRender];
} }
#pragma mark - Helpers
- (void)scrollToPageAtIndex:(NSInteger)index animated:(BOOL)animated
{
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:index inSection:0];
[self.view scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionLeft animated:animated];
}
#pragma mark - ASCollectionViewDataSource #pragma mark - ASCollectionViewDataSource
- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForItemAtIndexPath:(NSIndexPath *)indexPath - (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForItemAtIndexPath:(NSIndexPath *)indexPath