Skip to main content
b
6d ago

Can't listen to the artboard's events after reset()

Hi, I'm facing a problem. I change the artboard at runtime using the reset() method, but after switching to the new artboard, I can't listen to the artboard's events - web, any ideas?

6 replies
b
6d ago

Do you mind posting your code? Also, which web runtime are you using? React, JS, canvas, webgl2?

b
3d ago

useEffect(() => {

const artboardName = Artboard${currentArtboard};

if (rive?.activeArtboard && rive.activeArtboard !== artboardName) {

rive?.reset({

artboard: Artboard${currentArtboard},

autoplay: true,

stateMachines: 'State Machine',

});

}

}, [currentArtboard]);

3d ago
[deleted]
b
3d ago

Here is the link to the code. I hope you can help me resolve this issue. Thank you very much!

3d ago

I'm still looking into what's going on with reset, but you might want to consider slightly different approach. Are you familiar with Solos? https://rive.app/community/doc/solos/docXEEYoqU0R

Solos would let you display either Artboard 1 or Artboard 2 inside of a parent artboard without needing to manage them in code. I've included an example.

swapArtboards.rev
808 KB
b
2d ago

Thank you. Using solo was the first approach I tried. It’s quite convenient, but the downside is that I can’t listen to events from a nested artboard. I have to recreate many events to link them back to the nested artboard. Replacing a nested artboard means relinking those events, which is a bit cumbersome and time-consuming. That’s why I’m hoping to find a better solution.

Additionally, I’ve encountered a major issue where a nested artboard within another nested artboard doesn’t work properly. For example, in the Home artboard, I have a nested artboard for a button (which still works at this level). However, when Home becomes a nested artboard in the Main artboard, the button stops working.