mifi / react-lottie-player

Fully declarative React Lottie player
MIT License
505 stars 53 forks source link

Trying to get animation control to work #41

Closed Rassibassi closed 2 years ago

Rassibassi commented 3 years ago

Hi,

thanks for this great package. I am using it, but now need an additional functionality.

Another lottie react (lottie-react-web) package offers such feature. I tried to implement the feature into react-lottie-player, however now I am stuck and hoping for some help. This is wrapped into a pull request such that I could share my code.

lottie-react-web supports changing animation at runtime, as you can read at the bottom of the readme.

I've got an example (in the folder example2 of this PR), there I tried to implement the changes in a local example2/src/Lottie.js file, which is the same as the src/index.js. This example also includes a working example using lottie-react-web with some dirty un/commenting. However, I would like to use your package, so I gave it a shot.

First, lottie-api is required to get the functionality, and then there are only some minor additions to your code and another ref useRef. However, nothing changes as expected when animationControl is changed through the toggle button in my example example2/src/App.js.

If you have time, it would be nice if you could have a look, as I'm a bit lost on why the expected effects do not take place.

Thanks, Rasmus

Rassibassi commented 3 years ago

Oh, I forgot, the lottie animation file is taken from this example: https://codepen.io/driezis/pen/zYOQLrw

mifi commented 2 years ago

Hi! I completely forgot about this one. I may be opne for adding something like this, but I'm not sure if everyone wants the added 29kb lottie-api. Maybe we could make a way of providing it and sending it in as a prop to react-lottie-player for those who want to use this functionality. I don't have much time to look into this right now, but I'm open for adding something like this. I'm not sure why a separate example project is needed for this though?

Rassibassi commented 2 years ago

Thanks for the reply. Since I opened this issue I moved to svelte and I don't really need this feature anymore :)