Gamote / lottie-react

A lightweight React library for rendering complex After Effects animations in real time using Lottie.
https://lottiereact.com
Other
795 stars 58 forks source link

How to set a Speed for the Lottie ? #73

Open Hamdysaad20 opened 2 years ago

Hamdysaad20 commented 2 years ago

hi , thank you for the amazing library . can you help me with this issue , i can't find a way to set the speed for this library

GhostyJade commented 2 years ago

I think you can try to get the lottieRef ref object from the component and call the setSpeed from there.

DaphneChang commented 2 years ago

I have the same question. How can I set the default speed of it instead of using the "setSpeed" function ? The function makes the config become complicated.

GhostyJade commented 2 years ago

@DaphneChang Currently (for what I've seen in the source code), is not possible to pass the speed value as a prop to the Lottie component... What do u mean with "makes the config become complicated"?

bfaulk96 commented 1 year ago

I'm using the onDOMLoaded attribute to essentially do what you're asking (except in my example I was trying to set the direction to reverse):

const lottieRef = useRef(null)

return <Lottie animationData={someLottie} autoplay loop lottieRef={lottieRef}
  onDOMLoaded={() => lottieRef.current?.setDirection(-1)} 
/>
Keyvan-RezaeiF commented 1 year ago

Hi everyone, this package had an update 4 months ago. I want to know if this issue is fixed or not.

GhostyJade commented 1 year ago

@Keyvan-RezaeiF it was a dependency update, not a feature update.

Edit: it also fixes #77