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

[Feature Request] onLoad callback #216

Open
ridwansameer opened this issue Dec 20, 2023 · 3 comments
Open

[Feature Request] onLoad callback #216

ridwansameer opened this issue Dec 20, 2023 · 3 comments

Comments

@ridwansameer
Copy link

Description

I've noted the web version has an onLoad callback when loading files over the URL. I dug through the code and I think this may not be even exposed from native iOS/Android level?

Would be great for us to have this functionality so we could show some sort of loaders while waiting for the Rive animation to be loaded. If this can be done on the native side I would be happy to write the bindings on React native's JS layer :)

Provide a Repro

N/A

Expected behavior

Have an onLoad Callback

@cosimochellini
Copy link

I agree, I'm implementing animations with state, and it's quite complicated to find a way to understand the right time to set the initial state

For the moment this is the workaround but it seems very complicated to maintain

const BlobAnimation = () => {
  const [mood, setMood] = useState(-2);
  const [riveRef, setRiveRef] = useState<RiveRef | null>(null);

  useEffect(() => {
    if (!riveRef) return;

    setTimeout(() => {
      riveRef.setInputState(blobStateMachineName, 'mood', mood);
    }, 300);
  }, [mood, riveRef]);

  return (
    <>
      <Rive
        ref={setRiveRef}
        autoplay
        url={blobUrl}
        stateMachineName={blobStateMachineName}
        style={{ width: 200, height: 200 }}
      />
      <Button onPress={() => setMood((value) => value + 1)} label="mood + 1" />
    </>
  );
};

@edgartoomik
Copy link

Any updates?

1 similar comment
@SergeyYurkevich
Copy link

Any updates?

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

4 participants