rive-react icon indicating copy to clipboard operation
rive-react copied to clipboard

No Repeat/OnComplete support.

Open KwehDev opened this issue 1 year ago • 1 comments

Hello!

I was wondering if the Rive-React player has built-in support for repeating animations, and for triggering callbacks once an animation is complete.

For repeating, we'd like to perform an animation upon button click, and perform it again for subsequent clicks. We can do this with the following;

onClick={() => {
  rive.reset()
  rive.play()
}

Which gives us the intended behavior.

On the other hand, we are able to perform an onComplete check by using the onStop listener provided by useRive, as it is triggered upon animation completion. However, if we use the above reset/play logic, onStop is triggered twice.

Is there any built-in support for these use-cases, or a recommended approach to accomplish this?

Thanks.

KwehDev avatar Apr 14 '23 11:04 KwehDev