Natively driven translation transforms using Animated.Value expected results do not match JS driven if initialValue is non-zero #13452
Labels
Area: Animation
bug
Old Architecture
Broad category for issues that apply to the RN "old" architecture of Cxx Modules + Paper
Partner: Microsoft
Workstream: Component Parity
Close the parity gap between RNW and RN for core RN components and their supporting APIs.
Milestone
Problem Description
There are a few bugs at play, though all possibly caused by the same issue. When attempting to use natively driven Animated.Value to transform and translate a view from a non-zero starting point, the view is rendered in the incorrect location. With work arounds we can get this to work, but there is then a further bug. If the transform value needs to be modified before or after an animation,
setValue
cannot be called on the Value instance. Furthermore, to fix this we can opt-out of Composition native animation, but there is no publically available way to create an Animated.Value instance starting as a natively driven non-composition value.So to summarize the three bugs.
new Animated.Value(initialValue, { useNativeDriver: true, platformConfig: { useComposition: false }})
will not pass the platform config down to native. This appears to be due to React Native's AnimatedValue constructor calling __makeNative() with no params unlike other Animated variants that do pass in the platform config.Steps To Reproduce
First bug:
const translateYValue= useAnimatedValue(100, { useNativeDriver: true };
<Animated.View style={{ transform: [{ translateY: translateYValue }] }}/>
Second bug:
const translateYValue= useAnimatedValue(0, { useNativeDriver: true };
useEffect(() => translateYValue.setValue(100), []);
Third bug:
Expected Results
Bug #1: Value performs like JS or non-composition animation. As a developer, I can use animated values that have a non-zero initial value
Bug #2: Value performs like JS or non-composition animation. As a developer, I can set the instance's value at any point while mounted to change the value natively
Bug #3: I have a way to turn off composition animation per animated node. Instead, I have to use a hidden function
__setPlatformConfig
.CLI version
12.3.6, 13.6.8
Environment
Community Modules
No response
Target Platform Version
None
Target Device(s)
Desktop
Visual Studio Version
Visual Studio 2022
Build Configuration
Release
Snack, code example, screenshot, or link to a repository
The white box is where the content is positioned without a transform, the red box is where they are supposed to be after the transform is applied.
The text was updated successfully, but these errors were encountered: