diff --git a/AsyncDisplayKit/ASPagerNode.h b/AsyncDisplayKit/ASPagerNode.h index d14efeab07..36355c91dd 100644 --- a/AsyncDisplayKit/ASPagerNode.h +++ b/AsyncDisplayKit/ASPagerNode.h @@ -14,6 +14,8 @@ @property (weak, nonatomic) id dataSource; +- (void)scrollToPageAtIndex:(NSInteger)index animated:(BOOL)animated; + @end @protocol ASPagerNodeDataSource diff --git a/AsyncDisplayKit/ASPagerNode.m b/AsyncDisplayKit/ASPagerNode.m index 7112816ecf..fef60e2e2d 100644 --- a/AsyncDisplayKit/ASPagerNode.m +++ b/AsyncDisplayKit/ASPagerNode.m @@ -49,6 +49,14 @@ [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 - (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForItemAtIndexPath:(NSIndexPath *)indexPath