Fix animating colors direclty from useAnimatedStyle #2782
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes the ability to use color animations directly in useAnimatedStyle.
Changes
This diff changes the way
parseColors
method works. Before this change we'd run all the updates for color properties (e.g.backgroundColor
) via that method and expect it to update color to a normalized form. This way we'd get normalized values to send to the native side. However, if you'd specifywithTiming(someColor)
as a value, the parser would returnundefined
and override that animated value. As a result removing that animation object from styles would result in disabling that animation completely (the code fragment responsible for running animation would never see it). What we should be doing instead is to allow animated color values to be passed as animation objects and be parsed only when they are turned into actual values when the animation is running.Before
To test it add a code that has style like this:
Before this change the color would not change after we switch the toggle
After
After this change the color propertly animated when toggle variable is flipped.
Test code and steps to reproduce