fix: Make withDecay
compatible with withRepeat
#6772
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.
Summary
As it was discovered in #6757,
withRepeat
run along withwithDecay
triggered repeat only once, even if the number of repeats was greater.withDecay
relies on the value ofvelocity
. TheinitialVelocity
is the velocity provided (or default), and during the animation, thevelocity
value decreases, causing the animated object to slowly stop. The problem was, after first repeat thevelocity
was already decreased to almost zero and the animation could not run, as it had no momentum.I was able to fix that by adjusting
finished
prop, and resetingvelocity
to initial value, iffinished
istrue
.Fixes #6757
Before:
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2024-11-25.at.12.07.07.mp4
After:
Screen.Recording.2024-11-28.at.14.18.54.mov
Test plan
Run provided code snipped on Fabric example
Code snipped provided in issue