Refactor nodeDidRelayoutWithSizeChange: -> nodeDidRelayout:sizeChanged:

This commit is contained in:
Adlai Holler
2015-11-30 19:29:27 -08:00
parent 04d93532bc
commit 0ee1fd82dc
4 changed files with 11 additions and 10 deletions

View File

@@ -15,13 +15,13 @@ typedef NSUInteger ASCellNodeAnimation;
@protocol ASCellNodeLayoutDelegate <NSObject>
/**
* Notifies the delegate that the specified cell node has done a relayout
* that resulted in a change of `calculatedSize`.
* Notifies the delegate that the specified cell node has done a relayout.
* The notification is done on main thread.
*
* @param node A node informing the delegate about the relayout.
* @param sizeChanged `YES` if the node's `calculatedSize` changed during the relayout, `NO` otherwise.
*/
- (void)nodeDidRelayoutWithSizeChange:(ASCellNode *)node;
- (void)nodeDidRelayout:(ASCellNode *)node sizeChanged:(BOOL)sizeChanged;
@end
/**

View File

@@ -56,9 +56,10 @@
CGSize oldSize = self.calculatedSize;
[super setNeedsLayout];
if (_layoutDelegate != nil && !CGSizeEqualToSize(oldSize, self.calculatedSize)) {
if (_layoutDelegate != nil) {
BOOL sizeChanged = !CGSizeEqualToSize(oldSize, self.calculatedSize);
ASPerformBlockOnMainThread(^{
[_layoutDelegate nodeDidRelayoutWithSizeChange:self];
[_layoutDelegate nodeDidRelayout:self sizeChanged:sizeChanged];
});
}
}

View File

@@ -913,11 +913,11 @@ static BOOL _isInterceptedSelector(SEL sel)
#pragma mark - ASCellNodeDelegate
- (void)nodeDidRelayoutWithSizeChange:(ASCellNode *)node
- (void)nodeDidRelayout:(ASCellNode *)node sizeChanged:(BOOL)sizeChanged
{
ASDisplayNodeAssertMainThread();
if (_queuedNodeSizeUpdate) {
if (!sizeChanged || _queuedNodeSizeUpdate) {
return;
}

View File

@@ -910,11 +910,11 @@ static BOOL _isInterceptedSelector(SEL sel)
#pragma mark - ASCellNodeLayoutDelegate
- (void)nodeDidRelayoutWithSizeChange:(ASCellNode *)node
- (void)nodeDidRelayout:(ASCellNode *)node sizeChanged:(BOOL)sizeChanged
{
ASDisplayNodeAssertMainThread();
if (_queuedNodeHeightUpdate) {
if (!sizeChanged || _queuedNodeHeightUpdate) {
return;
}