react-native
react-native copied to clipboard
fix animated value synchronization on detach
Summary
When an animated value node is detached, and native animations are enabled, the value is synchronized with the native state. However, this incorrectly includes the offset in the value.
The problem was introduced with this commit https://github.com/facebook/react-native/commit/d92284216f4b079079f7ee479f35c94c900bc701. This PR adds a new method called getState that returns both the raw value and offset of the animated value. I added a new method to avoid breaking changes.
Changelog
[General] [Fixed] - Fix synchronization of animation state when animation completes when using native animations.
Test Plan
| Platform | Engine | Arch | Size (bytes) | Diff |
|---|---|---|---|---|
| ios | - | universal | n/a | -- |
Base commit: f592ad05096542e0d010c1972b7fe1f76687e78e
| Platform | Engine | Arch | Size (bytes) | Diff |
|---|---|---|---|---|
| android | hermes | arm64-v8a | 9,177,374 | -73 |
| android | hermes | armeabi-v7a | 8,702,655 | -178 |
| android | hermes | x86 | 9,620,032 | -168 |
| android | hermes | x86_64 | 9,585,858 | -174 |
| android | jsc | arm64-v8a | 10,814,158 | +131 |
| android | jsc | armeabi-v7a | 9,730,721 | +33 |
| android | jsc | x86 | 10,852,231 | +47 |
| android | jsc | x86_64 | 11,459,562 | +37 |
Base commit: f592ad05096542e0d010c1972b7fe1f76687e78e
Instead, what do you think about making the method signature:
getValueOffset(tag: number, callback: (value: number, offset: number) => void): void
It saves from having to create the object, and it is also more clear than getState.
And is the plan to deprecate and eventually delete getValue?
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
I'd like to learn more on the context with this PR:
- We want to carry over the animated value from unmounted native view, so that if the same native animated value is used later, we can resume animation from the last value.
- With the current implementation, we are actualy getting the animated value + offset. The offset is used to compensate things with a certain animation (doc).
- However, the problem seems when resuming animated value, the offset could be different, and we don't want to preserve the offset, but only the value?
Can you show an example where item 3 is happening and caused issues? There's no linked issues in this PR, nor test plan. Those are important for me to help merge this faster.
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This PR was closed because it has been stalled for 7 days with no activity.