This commit is contained in:
Michael Schneider 2016-11-14 10:53:26 -08:00
parent dcc54c0d36
commit b0eb2f81c2
5 changed files with 7 additions and 35 deletions

View File

@ -235,7 +235,6 @@
return;
_contentSpacing = contentSpacing;
[self setNeedsLayout];
[self invalidateSize];
}
@ -252,7 +251,6 @@
return;
_laysOutHorizontally = laysOutHorizontally;
[self setNeedsLayout];
[self invalidateSize];
}

View File

@ -121,7 +121,12 @@ static NSMutableSet *__cellClassesForVisibilityNotifications = nil; // See +init
- (void)didInvalidateSize
{
CGSize oldSize = self.calculatedSize;
CGSize newSize = [self layoutThatFits:[self constrainedSize]].size;
ASSizeRange constrainedSize = ASSizeRangeMake(CGSizeZero, CGSizeMake(CGRectGetWidth(self.bounds), CGFLOAT_MAX));
if (_interactionDelegate != nil) {
constrainedSize = [_interactionDelegate constrainedSizeForNode:self];
}
CGSize newSize = [self layoutThatFits:constrainedSize].size;
if (CGSizeEqualToSize(oldSize, newSize) == NO) {
self.frame = {self.frame.origin, newSize};
@ -173,14 +178,6 @@ static NSMutableSet *__cellClassesForVisibilityNotifications = nil; // See +init
}
}
- (ASSizeRange)constrainedSize
{
if (_interactionDelegate != nil) {
return [_interactionDelegate constrainedSizeForNode:self];
}
return ASSizeRangeMake(CGSizeZero, CGSizeMake(CGRectGetWidth(self.bounds), CGFLOAT_MAX));
}
- (void)setSelected:(BOOL)selected
{
if (_selected != selected) {

View File

@ -26,19 +26,6 @@ NS_ASSUME_NONNULL_BEGIN
@class ASDisplayNode;
// TODO: Extract to ASDisplayNode+Layout.h
// ASDisplayNodeSizingDelegate / ASDisplayNodeSizingHandlers
@protocol ASDisplayNodeSizingDelegate<NSObject>
@required
/**
Called after the display node state update happened (layout invlidation) that could lead to a
The delegate can use this callback to appropriately resize the node frame to fit the new
node size. The node will not resize itself.
*/
- (void)displayNodeDidInvalidateSize:(ASDisplayNode *)displayNode;
@end
/**
* UIView creation block. Used to create the backing view of a new display node.
*/
@ -267,11 +254,10 @@ extern NSInteger const ASDefaultDrawingPriority;
/** @name Managing dimensions */
//@property (nonatomic, readwrite, weak, nullable) id<ASDisplayNodeSizingDelegate> sizingDelegate;
// TODO: coalesc: Documentation
- (void)invalidateSize;
- (void)didInvalidateSize;
- (void)sizeToFit;
- (CGSize)sizeThatFits:(CGSize)size;
/**

View File

@ -712,13 +712,6 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
// Mark the node for layout in the next layout pass
[self invalidateCalculatedLayout];
// This is the root node. Let the delegate know that the size changed
// If someone calls `invalidateBlaBla TBD` we have to inform the sizing delegate of the root node to be able
// to let them now that a size change happened and it needs to calculate a new layout / size for this node hierarchy
// if ([self.sizingDelegate respondsToSelector:@selector(displayNodeDidInvalidateSize:)]) {
// [self.sizingDelegate displayNodeDidInvalidateSize:self];
// }
// Hook for subclasses to get size invalidation changes
[self didInvalidateSize];

View File

@ -28,8 +28,6 @@ static const NSInteger kImageHeight = 200;
@property (nonatomic, copy) NSString *imageCategory;
@property (nonatomic, strong) ASCollectionNode *collectionNode;
@property (nonatomic, strong) ASDisplayNode *backgroundNode;
@end