Skip to content

Commit

Permalink
Add setNeedsLayout to yoga tree changes. (facebookarchive#1361)
Browse files Browse the repository at this point in the history
  • Loading branch information
wiseoldduck authored and Adlai-Holler committed Mar 5, 2019
1 parent 96e6a6c commit babd81b
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 90 deletions.
16 changes: 15 additions & 1 deletion Source/ASDisplayNode+Layout.mm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
#import <AsyncDisplayKit/ASNodeController+Beta.h>
#import <AsyncDisplayKit/ASDisplayNode+Yoga.h>

@interface ASDisplayNode (ASLayoutElementStyleDelegate) <ASLayoutElementStyleDelegate>
@end

@implementation ASDisplayNode (ASLayoutElementStyleDelegate)

#pragma mark <ASLayoutElementStyleDelegate>

- (void)style:(ASLayoutElementStyle *)style propertyDidChange:(NSString *)propertyName {
[self setNeedsLayout];
}

@end

#pragma mark - ASDisplayNode (ASLayoutElement)

@implementation ASDisplayNode (ASLayoutElement)
Expand All @@ -42,8 +55,9 @@ - (ASLayoutElementStyle *)style

- (ASLayoutElementStyle *)_locked_style
{
ASAssertLocked(__instanceLock__);
if (_style == nil) {
_style = [[ASLayoutElementStyle alloc] init];
_style = [[ASLayoutElementStyle alloc] initWithDelegate:self];
}
return _style;
}
Expand Down
2 changes: 2 additions & 0 deletions Source/ASDisplayNode+Yoga.mm
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ - (void)_locked_removeYogaChild:(ASDisplayNode *)child

// YGNodeRef removal is done in setParent:
child.yogaParent = nil;
[self setNeedsLayout];
}

- (void)insertYogaChild:(ASDisplayNode *)child atIndex:(NSUInteger)index
Expand All @@ -115,6 +116,7 @@ - (void)_locked_insertYogaChild:(ASDisplayNode *)child atIndex:(NSUInteger)index

// YGNodeRef insertion is done in setParent:
child.yogaParent = self;
[self setNeedsLayout];
}

#pragma mark - Subclass Hooks
Expand Down
Loading

0 comments on commit babd81b

Please sign in to comment.