-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Table and collection views] Consider content inset when calculating (default) element size range #525
[Table and collection views] Consider content inset when calculating (default) element size range #525
Changes from all commits
c8b2cd3
f9d6b41
326849b
1243609
74bf005
13cd95b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,7 @@ - (instancetype)init | |
- (instancetype)initWithCollectionViewLayout:(ASPagerFlowLayout *)flowLayout; | ||
{ | ||
ASDisplayNodeAssert([flowLayout isKindOfClass:[ASPagerFlowLayout class]], @"ASPagerNode requires a flow layout."); | ||
ASDisplayNodeAssertTrue(flowLayout.scrollDirection == UICollectionViewScrollDirectionHorizontal); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The existing implementation of this class (e.g |
||
self = [super initWithCollectionViewLayout:flowLayout]; | ||
return self; | ||
} | ||
|
@@ -112,7 +113,15 @@ - (void)didLoad | |
|
||
- (NSInteger)currentPageIndex | ||
{ | ||
return (self.view.contentOffset.x / CGRectGetWidth(self.view.bounds)); | ||
return (self.view.contentOffset.x / [self pageSize].width); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The old implementation works as expected, but let's not assume that |
||
} | ||
|
||
- (CGSize)pageSize | ||
{ | ||
UIEdgeInsets contentInset = self.view.contentInset; | ||
CGSize pageSize = self.bounds.size; | ||
pageSize.height -= (contentInset.top + contentInset.bottom); | ||
return pageSize; | ||
} | ||
|
||
#pragma mark - Helpers | ||
|
@@ -142,7 +151,7 @@ - (NSInteger)indexOfPageWithNode:(ASCellNode *)node | |
- (CGSize)sizeForElements:(ASElementMap *)elements | ||
{ | ||
ASDisplayNodeAssertMainThread(); | ||
return self.bounds.size; | ||
return [self pageSize]; | ||
} | ||
|
||
#pragma mark - ASCollectionDataSource | ||
|
@@ -179,7 +188,7 @@ - (ASSizeRange)collectionNode:(ASCollectionNode *)collectionNode constrainedSize | |
} | ||
#pragma clang diagnostic pop | ||
|
||
return ASSizeRangeMake(self.bounds.size); | ||
return ASSizeRangeMake([self pageSize]); | ||
} | ||
|
||
#pragma mark - Data Source Proxy | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method isn't used anywhere.