Adds trampoline for inserting and deletion of nodes

Currently measurement always needs to happen on the main thread if implicit hierarchy management is enabled as adding and removing from nodes needs to happen on the main thread. We now will trampoline to the main thread to do the insertion and deletion of nodes.

This also resolves the issue that can occur if a node is already loaded deep in the layout hierarchy in the layout that the node is transforming to. Before insertion or deletion is happening we need to crawl the layout hierarchy to check that though.
This commit is contained in:
Michael Schneider
2016-06-28 16:41:57 -07:00
parent a77a6eaaf5
commit 01fed69b26
7 changed files with 206 additions and 20 deletions

View File

@@ -18,16 +18,45 @@
@interface ASLayoutTransition : NSObject <_ASTransitionContextLayoutDelegate>
/**
* Node to apply layout transition on
*/
@property (nonatomic, readonly, weak) ASDisplayNode *node;
@property (nonatomic, readonly, strong) ASLayout *pendingLayout;
/**
* Previous layout to transition from
*/
@property (nonatomic, readonly, strong) ASLayout *previousLayout;
- (instancetype)initWithNode:(ASDisplayNode *)node
pendingLayout:(ASLayout *)pendingLayout
previousLayout:(ASLayout *)previousLayout;
/**
* Pending layout to transition to
*/
@property (nonatomic, readonly, strong) ASLayout *pendingLayout;
/**
* Returns if the layout transition can happen asynchronously
*/
@property (nonatomic, readonly, assign) BOOL canTransitionAsynchronous;
/**
* Returns a newly initialized layout transition
*/
- (instancetype)initWithNode:(ASDisplayNode *)node pendingLayout:(ASLayout *)pendingLayout previousLayout:(ASLayout *)previousLayout NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
/**
* Insert and remove subnodes that where added or removed between the previousLayout and the pendingLayout
*/
- (void)applySubnodeTransition;
/**
* Insert all new subnodes that where added between the previous layout and the pending layout
*/
- (void)applySubnodeInsertions;
/**
* Remove all subnodes that are removed between the previous layout and the pending layout
*/
- (void)applySubnodeRemovals;
@end