LottieFiles / lottie-react

lottie web player as a react component
https://lottiefiles.com
MIT License
720 stars 80 forks source link

Speed is overriden #72

Closed leobenkel closed 2 years ago

leobenkel commented 2 years ago

Tell us about your environment

What did you do? Please explain the steps you took before you encountered the problem.

I have more than one lottie icon on a given page. it seems that the last one to load is setting the speed for all of them. I have one with speed="0.5" and 2 with a speed="2" and it seems that all of them behave at a speed of 2.

What did you expect to happen?

I would expect each lottie component to be independent.

I tried to edit the labels but i don't think i have the rights to do it.

leobenkel commented 2 years ago

at https://github.com/LottieFiles/lottie-react/blob/1934ce4f9cc8fb74f8c9e64765ab6e08464d239a/src/Player.tsx#L304

Shouldn't it be newInstance.setSpeed instead of lottie.setSpeed so it doesn't set it for all ?

samuelOsborne commented 2 years ago

Hi @leobenkel, I haven't managed to reproduce this error, are you using the latest version? Heres my codesandbox:

https://codesandbox.io/s/lottie-react-speed-test-veuux?file=/src/App.js

leobenkel commented 2 years ago

look at this one https://codesandbox.io/s/lottie-react-speed-test-forked-g1xzur?file=/src/App.js

samuelOsborne commented 2 years ago

@leobenkel Thanks, you're right it should be newInstance.setSpeed. Let me push up a fix and ping you back

leobenkel commented 2 years ago

cool thanks ! :)

samuelOsborne commented 2 years ago

Thanks @leobenkel this should be fixed in 3.4.2 :)

leobenkel commented 2 years ago

it works ! Thanks !