rive-app / rive-react

React runtime for Rive

Home Page:https://rive-app.github.io/rive-react

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rive new listeners

HidanZZ opened this issue · comments

Hi, i would like to know if there is a way to add the pointer move listener that has been added to rive to a rive component.

@HidanZZ The pointer move listener is supported under the hood. As long as the .riv file has a state machine with that listener, there shouldn't be any need to hook up or define the listener at runtime. Are you having troubles getting it to work on your end?

@zplata Yes i am having trouble with it, can you show me a code snippet demonstrating how to do it ?
Thanks.

@HidanZZ Yeah sure!

Here's an example using the basic default exported component. If all you need to do is display a state machine with listeners baked in at the Rive file in the editor, you can just use this.
https://codesandbox.io/s/restless-framework-bhy2dq?file=/src/App.js

I'm referencing an example from one of the Rive team members as the src here:
https://rive.app/community/2865-5957-forest-god/

Note that the listeners only work when the interaction is based within the Rive canvas space (not the whole page). For whole page interactions with the Rive canvas, you need to set that logic up manually. Hope this helps!

What version of this rive-react lib are you using?

@zplata Thanks, i got it working now.
I use version 3.0.18.
Thanks a lot again.