Improve measurement code for cell nodes (#3119)

This commit is contained in:
Michael Schneider
2017-03-03 09:24:04 -08:00
committed by GitHub
parent 93809bd4e7
commit 62d7e14ce1
7 changed files with 55 additions and 50 deletions

View File

@@ -32,6 +32,7 @@
#import <AsyncDisplayKit/ASSectionContext.h>
#import <AsyncDisplayKit/ASCollectionView+Undeprecated.h>
#import <AsyncDisplayKit/_ASHierarchyChangeSet.h>
#import <AsyncDisplayKit/CoreGraphics+ASConvenience.h>
/**
* A macro to get self.collectionNode and assign it to a local variable, or return
@@ -1563,6 +1564,15 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
}
}
- (BOOL)dataController:(ASDataController *)dataController presentedSizeForElement:(ASCollectionElement *)element matchesSize:(CGSize)size
{
NSIndexPath *indexPath = [self indexPathForNode:element.node];
UICollectionViewLayoutAttributes *attributes = [self layoutAttributesForItemAtIndexPath:indexPath];
CGRect rect = attributes.frame;
return CGSizeEqualToSizeWithIn(rect.size, size, FLT_EPSILON);
}
- (id<ASTraitEnvironment>)dataControllerEnvironment
{
return self.collectionNode;