Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit 10030df

Browse files
committed
Add scroll to page helper to ASPagerNode
1 parent ad4db73 commit 10030df

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

AsyncDisplayKit/ASPagerNode.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
@property (weak, nonatomic) id<ASPagerNodeDataSource> dataSource;
1616

17+
- (void)scrollToPageAtIndex:(NSInteger)index animated:(BOOL)animated;
18+
1719
@end
1820

1921
@protocol ASPagerNodeDataSource <NSObject>

AsyncDisplayKit/ASPagerNode.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ - (void)didLoad
4949
[self setTuningParameters:renderParams forRangeType:ASLayoutRangeTypeRender];
5050
}
5151

52+
#pragma mark - Helpers
53+
54+
- (void)scrollToPageAtIndex:(NSInteger)index animated:(BOOL)animated
55+
{
56+
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:index inSection:0];
57+
[self.view scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionLeft animated:animated];
58+
}
59+
5260
#pragma mark - ASCollectionViewDataSource
5361

5462
- (ASCellNode *)collectionView:(ASCollectionView *)collectionView nodeForItemAtIndexPath:(NSIndexPath *)indexPath

0 commit comments

Comments
 (0)