Skip to content

Commit

Permalink
[ASCollectionLayout] Fix element lookup for supplementary attributes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
craighowarth authored and nguyenhuy committed Dec 24, 2019
1 parent 88a640a commit b59c6d0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Source/Private/ASCollectionLayout.mm
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,12 @@ + (void)_measureElementsInRect:(CGRect)rect blockingRect:(CGRect)blockingRect la
if (NSUInteger count = blockingAttrs.count) {
ASDispatchApply(count, queue, 0, ^(size_t i) {
UICollectionViewLayoutAttributes *attrs = blockingAttrs[i];
ASCellNode *node = [elements elementForItemAtIndexPath:attrs.indexPath].node;
ASCellNode *node;
if (attrs.representedElementKind == nil) {
node = [elements elementForItemAtIndexPath:attrs.indexPath].node;
} else {
node = [elements supplementaryElementOfKind:attrs.representedElementKind atIndexPath:attrs.indexPath].node;
}
CGSize expectedSize = attrs.frame.size;
if (! CGSizeEqualToSize(expectedSize, node.calculatedSize)) {
[node layoutThatFits:ASCollectionLayoutElementSizeRangeFromSize(expectedSize)];
Expand All @@ -353,7 +358,12 @@ + (void)_measureElementsInRect:(CGRect)rect blockingRect:(CGRect)blockingRect la
__strong ASElementMap *strongElements = weakElements;
if (strongElements) {
UICollectionViewLayoutAttributes *attrs = nonBlockingAttrs[i];
ASCellNode *node = [elements elementForItemAtIndexPath:attrs.indexPath].node;
ASCellNode *node;
if (attrs.representedElementKind == nil) {
node = [elements elementForItemAtIndexPath:attrs.indexPath].node;
} else {
node = [elements supplementaryElementOfKind:attrs.representedElementKind atIndexPath:attrs.indexPath].node;
}
CGSize expectedSize = attrs.frame.size;
if (! CGSizeEqualToSize(expectedSize, node.calculatedSize)) {
[node layoutThatFits:ASCollectionLayoutElementSizeRangeFromSize(expectedSize)];
Expand Down

0 comments on commit b59c6d0

Please sign in to comment.