Scale animations not occurring from center of component (19H1+)
Environment
If you are using latest version:
react-native -v: 0.60.6react-native run-windows --info: System: OS: Windows 10 10.0.18363 CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz Memory: 18.01 GB / 31.84 GB Binaries: Node: 10.15.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.21.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.13.7 - C:\Program Files\nodejs\npm.CMD npmPackages: react: 16.8.6 => 16.8.6 react-native: 0.60.6 => 0.60.6 react-native-windows: 0.60.0-vnext.133 => 0.60.0-vnext.133 rnpm-plugin-windows: 0.3.5 => 0.3.5 Installed UWP SDKs: 10.0.14393.0 10.0.15063.0 10.0.16299.0 10.0.17134.0 10.0.17749.0 10.0.17763.0 10.0.18362.0
Then, specify:
- Target Platform Version(s): 10.0.18362.0
- Target Device(s): Desktop
- Visual Studio Version: 2017
- Build Configuration: Debug
Steps to Reproduce
Create a project using react-native-windows that uses scale animations (see reproducible example below).
Expected Behavior
Scale animation will occur at the center of the component, so the component will either grow or shrink from the center outwards in all directions.
Actual Behavior
Scale animation occurs at the top-left of the component, so it grows or shrinks from the top-left to the bottom-right.
I see that there is a block comment in FrameworkElementViewManager right above the function "ApplyTransformMatrix" that explains the process that RNW uses to make the animation happen about the center rather than the top-left corner of the component, and I have confirmed that the code does go through that process (ApplyTransformMatrix -> StartTransformAnimation -> GetTransformCenteringExpression), but the animation still occurs from the top-left of the component.
Reproducible Example
I created an example in base RN to show that it works in that case: https://snack.expo.io/@jagorrin/scale-animation-example
If the same code is used in a project consuming RNW, the scale animation will grow or shrink the component from the top-left to the bottom-right instead of from the center outwards in all directions.
Also, is there a workaround that can be used in the meantime until this is fixed?
Per @kmelmon, The possible workaround would be for you to implement a transform origin yourself. The idea would be to create a composite transform that has 3 components: -translate * scale * translate, where translate is a translation transform. The amount to translate would need to be computed based on the size of the component. Others have done this in plain vanilla RN to achieve different transform origins (since there is no transform-origin property in RN).
This looks like a bug and a recent regression.