-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic from
value doesn't update after state change in MotiView
#356
Comments
This is the entire purpose of the from prop. It’s the initial state. If you want to make reactive changes, you can pass them to them animate prop and they will update |
I can see the case you want it for is for repeating animations. Perhaps you could instead try a sequence inside of Alternatively you could change the |
@nandorojo I see. I have tried the sequence animation, but I also need to know when the animation has ended to trigger the change of
|
you can pass objects to the sequence values, each of which can receive its own callback |
(i think…) one argument of |
I tried to check the
but since both first and third log have attempted sequence value 100, it's not possible (just from the log data themselves) to know when the sequence has ended
Thanks, didn't know that. This seems to work in the moti stackblitz template correctly and the
However, when I'm trying the same code in expo Here's the repo testing the same code in expo, doesn't seem to run in stackblitz correctly unfortunately |
editing repeat animations is always a tricky thing, since the component has to retain state across renders. is it possible to set |
Adding |
Got it. I do wonder if perhaps reanimated is the right candidate for this one. Unless there’s a repro that works in reanimated and not moti |
There is a repro that works in reanimated and not in moti. This works as expected in reanimated:
and this would be the same code in Moti (based on your suggestion to create a sequence and put
I believe it comes down to moti lacking more granular onAnimationEnd callbacks that are available in reanimated - in this case there's no "on repeat end" callback, that would tell me with certainty when the full animation is completed. And the "on sequence step end" callback doesn't seem to work properly in expo, since it fires multiple times instead of firing only once after the specific sequence step has ended. I've updated the examples in the repo with both of these. |
you’re correct, there’s no onRepeatEnd callback. that’s an interesting case I hadn’t come across. I wonder what the best API for this would be… |
I assume reanimated has the same issue if you add a callback on the last item? assuming you used a sequence for the repro and not a basic withRepeat |
Even when using sequence in reanimated and putting the callback at last item of the sequence, the code still works as expected and the callback fires as expected only after the last step of the sequence is completed.
So reanimated doesn't have the same issue as moti. |
for a true repro you can drop the shared value and directly set the style in useAnimatedStyle. this is what moti does |
I'm assuming you mean like this:
Still works correctly in reanimated. |
got it, so it sounds like identified bug is that onDidAnimate for sequence items fires multiple times, but only on native |
correct, the bug happens only on expo |
I think this is only for transforms, and I think it's because it may be firing for both |
Is there an existing issue for this?
Do you want this issue prioritized?
Current Behavior
The value used in the from property of the MotiView animation does not update dynamically after the corresponding state variable is updated. As a result, the initial value remains unchanged throughout the animation despite the state update.
Expected Behavior
The value in the from property should update to the new state value after the state change. The animation should then use this updated value for subsequent animations.
Steps To Reproduce
Versions
Screenshots
No response
Reproduction
https://stackblitz.com/edit/nextjs-czkf4w?file=pages%2Findex.tsx
The text was updated successfully, but these errors were encountered: