From 34c7e7610cadec47204750977e17fc3baf2ee800 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Mon, 31 Oct 2016 14:21:58 -0700 Subject: [PATCH] Fix setAnimatedNodeValue in Native Animated on iOS 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 https://github.com/facebook/react-native/pull/10643 Differential Revision: D4106346 fbshipit-source-id: 7c639e03ded87058354340f1179f8b75be423e84 --- Libraries/NativeAnimation/RCTNativeAnimatedModule.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Libraries/NativeAnimation/RCTNativeAnimatedModule.m b/Libraries/NativeAnimation/RCTNativeAnimatedModule.m index 5c76c10e4..f08824395 100644 --- a/Libraries/NativeAnimation/RCTNativeAnimatedModule.m +++ b/Libraries/NativeAnimation/RCTNativeAnimatedModule.m @@ -183,6 +183,10 @@ RCT_EXPORT_METHOD(setAnimatedNodeValue:(nonnull NSNumber *)nodeTag RCTValueAnimatedNode *valueNode = (RCTValueAnimatedNode *)node; valueNode.value = value.floatValue; [valueNode setNeedsUpdate]; + + [self updateViewsProps]; + + [valueNode cleanupAnimationUpdate]; } RCT_EXPORT_METHOD(setAnimatedNodeOffset:(nonnull NSNumber *)nodeTag @@ -265,6 +269,12 @@ RCT_EXPORT_METHOD(stopListeningToAnimatedNodeValue:(nonnull NSNumber *)tag) body:@{@"tag": node.nodeTag, @"value": @(value)}]; } +- (void)updateViewsProps +{ + for (RCTPropsAnimatedNode *propsNode in _propAnimationNodes) { + [propsNode updateNodeIfNecessary]; + } +} #pragma mark -- Animation Loop