Open Thristhart opened 5 years ago
Interesting scenario. It's not immediately clear whether this is or is not expected behavior, as in what sort of memory do animations have. First step would be to try this on Android/iOS to clarify that expected behavior.
Confirmed in snack this isn't expected behavior for other platforms.
I assume this is related to #3280, given that #3281 comments out target.StopAnimation()
Comment from @marlenecota:
Debugged issue #3460 where an animated View is not reset after the animation is removed. There’s a lot of Animated code, so it’s going to take a little time to figure out how they all work together, but it looks like there’s an unimplemented “ResetDefaultValues” function in PropsAnimatedNode that needs to be called when it is disconnected from the View. Unfortunately the original value is not stored anywhere, so I am trying to figure out where it would go. I spoke with the Xbox guys and they have a workaround for this, so it is not currently blocking and are ok waiting for a fix.
Given presence of workaround, moving this to M5.
This also blocks use of native animations in some scenarios for us as well.
Here's another repro for this: https://github.com/rozele/react-native-windows/tree/repro3460
Here's the "expected" behavior using the JS animation driver:
https://user-images.githubusercontent.com/1106239/149194070-bfb66137-07c1-484d-97da-e00963d45c31.mp4
Here's the "actual" behavior using the composition native animation driver:
https://user-images.githubusercontent.com/1106239/149194090-278cb9c9-ae1b-42bd-8aa2-3ab52f13a7eb.mp4
Notice the translateX value never resets to 0.
Re-opening, as this is technically still a bug for the composition-based NativeAnimated implementation and the tick-based implementation is opt-in.
For a temporary workaround use:
// Animated.timing is an example, same syntax for any animation driver
Animated.timing({
/* ... */,
useNativeDriver: true,
platformConfig: {
useComposition: false,
}
);
Environment
react-native -v
:npm ls rnpm-plugin-windows
:npm ls react-native-windows
:node -v
:npm -v
:Then, specify:
Steps to Reproduce
Animated.View
that contains a transform or opacity set to anAnimated.Value
Animated.timing
to animate thatAnimated.Value
to a new value, withuseNativeDriver: true
Animated.View
such that it no longer has theAnimated.Value
in its stylesExpected Behavior
The transform or opacity would reset to initial values. A View translated to the right previously would have that translation removed.
Actual Behavior
The transform or opacity remain applied, even though the style no longer contains those values.
Reproducible Demo