rive not change animation
See original GitHub issueHey, I try to do a dark mode vs light mode animation
it the same animation with different color
I try to replace the RIV file on state change but the canvas does not update and I see the old animation. then I try to do in the Riv File 2 different animation with do name and change the animation
const params = {
src: RiveAnimation,
autoplay: true,
animations: isDark ? "dark" : "light", // this is not working
};
const { RiveComponent, rive } = useRive(params);
useEffect(() => {
if (rive) {
if (isDark) {
console.log("dark");
rive.stop("light");
rive.play("dark");
} else {
rive.stop("dark");
rive.play("light");
}
console.log(rive.playingAnimationNames);
}
}, [isDark, rive]);
and the animation does not update as well
any idea how to fix this?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
New Animation Edit not showing up in Rive File#520 - Sign in
Added animated text, which shows up when in Animation mode and when rendered to Cloud Renderer. However, the file is missing the animation...
Read more >Flutter Rive - animation doesn't change when ... - Stack Overflow
I tried to play with boolean input and it worked really nice, but changing number input won't change the animation at all.
Read more >How do I change between animation names? #26 - GitHub
The class 'RiveFile' doesn't have an unnamed constructor. Try using one of the named constructors defined in 'RiveFile'. and the line if (file....
Read more >Runtime - Rive Feedback
As I understand we can change animation only if it is provided by animation itse ... Hi, may be is crazy:) do you...
Read more >rive | Flutter Package - Pub.dev
RiveAnimation now takes lists of animation and state machine names and plays ... Fixing an issue with StateMachine changes not being applied on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks a lot for the quick answer and for this plugin - The solution works great, I also understood the problem with my animation.
@gzaban Had a look into this. The easiest fix is to call
reset()
in between stopping and playing an animation.From looking at the file, it looks like your light animation overwrites the fill, but the dark animation doesn’t (since it’s already set on the design). This is why changing from dark to light works but not light to dark. When you stop an animation, any changes made to the artboard by previous animations persist and aren’t undone unless you call reset. E.g Let say I have a circle who’s animation changed it’s size bigger and smaller in a loop, if I stopped the animation while it was big, the circle would remain big. That’s essentially what’s happening here. Your light animation sets the fill on the hat and chest but the dark animation doesn’t. So you could fix the file such that the dark animation also sets the fill, but calling
reset()
works fine here as well 😃.Another idea is to have a state machine for this file, with a toggle input between light and dark. Again not necessary, but could be worth exploring.