Skip to content

Commit

Permalink
Fix setAnimatedNodeValue in Native Animated on iOS
Browse files Browse the repository at this point in the history
Summary:
`setAnimatedNodeValue` currently does not update views if there is no animation currently running. This simply updates the view immediately instead of relying on the animation loop. Extracted it out in a function to be able to use it for native `Animated.event` too.

**Test plan**
Tested this in an app using native driven animations with `NavigationCardStackPanResponder` that makes use of `setValue` to update `Animated.Values` during the back gesture.
Closes facebook#10643

Differential Revision: D4106346

fbshipit-source-id: 7c639e03ded87058354340f1179f8b75be423e84
  • Loading branch information
janicduplessis authored and Facebook Github Bot committed Oct 31, 2016
1 parent 3ac3749 commit 34c7e76
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Libraries/NativeAnimation/RCTNativeAnimatedModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ - (dispatch_queue_t)methodQueue
RCTValueAnimatedNode *valueNode = (RCTValueAnimatedNode *)node;
valueNode.value = value.floatValue;
[valueNode setNeedsUpdate];

[self updateViewsProps];

[valueNode cleanupAnimationUpdate];
}

RCT_EXPORT_METHOD(setAnimatedNodeOffset:(nonnull NSNumber *)nodeTag
Expand Down Expand Up @@ -265,6 +269,12 @@ - (void)animatedNode:(RCTValueAnimatedNode *)node didUpdateValue:(CGFloat)value
body:@{@"tag": node.nodeTag, @"value": @(value)}];
}

- (void)updateViewsProps
{
for (RCTPropsAnimatedNode *propsNode in _propAnimationNodes) {
[propsNode updateNodeIfNecessary];
}
}

#pragma mark -- Animation Loop

Expand Down

0 comments on commit 34c7e76

Please sign in to comment.