Skip to content
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

Get current frameTime or frameCount #189

Open
smblee opened this issue Jul 12, 2023 · 1 comment
Open

Get current frameTime or frameCount #189

smblee opened this issue Jul 12, 2023 · 1 comment

Comments

@smblee
Copy link

smblee commented Jul 12, 2023

Hello -- Is there a way to either grab or reactively listen to the current frameTime and/or frameCount?

I tried using the rive.frameCount value and it doesn't seem to be returning what i would expect (the number doesn't continue to increment)

@zplata
Copy link
Contributor

zplata commented Jul 19, 2023

Hello! There isn't a way to subscribe to a specific frame in an animation, but with the latest version, 3.0.55 of this runtime library, you can provide a callback to useRive() via an onAdvance property, where the library will invoke your provided callback at the end of a given animation loop once Rive has drawn the current frame onto a canvas and pass back the elapsed time (in seconds) since the last frame draw.

Looks something like:

useRive({
  ...
  onAdvance: (time: number) => {
    console.log("time since last draw", time);
  }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants