Skip to content
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

Correct attributes lookup for supplementary elements. #1318

Merged
merged 2 commits into from
Mar 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2017,7 +2017,13 @@ - (BOOL)dataController:(ASDataController *)dataController presentedSizeForElemen
ASDisplayNodeFailAssert(@"Data controller should not ask for presented size for element that is not presented.");
return YES;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the condition above, indexPathForNode:, may also need to be updated to check e.g. indexPathForSupplementaryElement: ofKind: -- or maybe we can implement (or use if existing) indexPathForElement:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah indexPathForNode: does appear to lead to indexPathForElement:, which itself just looks up in _elementToIndexPathMap, which I don't know what is but isn't an OS call so maybe it's just fine?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep indexPathForNode: is fine here, it works for supplementaries and for items.

}
UICollectionViewLayoutAttributes *attributes = [self layoutAttributesForItemAtIndexPath:indexPath];

UICollectionViewLayoutAttributes *attributes;
if (element.supplementaryElementKind == nil) {
attributes = [self layoutAttributesForItemAtIndexPath:indexPath];
} else {
attributes = [self layoutAttributesForSupplementaryElementOfKind:element.supplementaryElementKind atIndexPath:indexPath];
}
return CGSizeEqualToSizeWithIn(attributes.size, size, FLT_EPSILON);
}

Expand Down