Fix Fabric animation association

Summary:
Before I was looking at the animation nodeTag rather than the view reactTag to determine if it was Fabric, so sometimes we would do an early fabric flush on non-fabric views, or miss it on fabric ones.

This fixes it by associating animations with fabric based on the reactTag of the view that is associated with the animation nodeTag.

Reviewed By: shergin

Differential Revision: D14504446

fbshipit-source-id: 75a1394b34436556daf9c33dc63743df33c2fb19
This commit is contained in:
Spencer Ahrens
2019-03-18 13:24:57 -07:00
committed by Facebook Github Bot
parent 8b206cab82
commit 5ebef7a214

View File

@@ -19,6 +19,7 @@ typedef void (^AnimatedOperation)(RCTNativeAnimatedNodesManager *nodesManager);
// Operations called before views have been updated.
NSMutableArray<AnimatedOperation> *_preOperations;
NSMutableDictionary<NSNumber *, NSNumber *> *_animIdIsManagedByFabric;
NSMutableDictionary<NSNumber *, NSNumber *> *_animatedNodeIsManagedByFabric;
}
RCT_EXPORT_MODULE();
@@ -87,7 +88,7 @@ RCT_EXPORT_METHOD(startAnimatingNode:(nonnull NSNumber *)animationId
[self addOperationBlock:^(RCTNativeAnimatedNodesManager *nodesManager) {
[nodesManager startAnimatingNode:animationId nodeTag:nodeTag config:config endCallback:callBack];
}];
if (RCTUIManagerTypeForTagIsFabric(nodeTag)) {
if ([_animatedNodeIsManagedByFabric[nodeTag] boolValue]) {
_animIdIsManagedByFabric[animationId] = @YES;
[self flushOperationQueues];
}
@@ -137,6 +138,9 @@ RCT_EXPORT_METHOD(connectAnimatedNodeToView:(nonnull NSNumber *)nodeTag
viewTag:(nonnull NSNumber *)viewTag)
{
NSString *viewName = [self.bridge.uiManager viewNameForReactTag:viewTag];
if (RCTUIManagerTypeForTagIsFabric(nodeTag)) {
_animatedNodeIsManagedByFabric[nodeTag] = @YES;
}
[self addOperationBlock:^(RCTNativeAnimatedNodesManager *nodesManager) {
[nodesManager connectAnimatedNodeToView:nodeTag viewTag:viewTag viewName:viewName];
}];