MicheleBertoli / react-count-to

Animated counter component for React.js
http://react-count-to.herokuapp.com
MIT License
61 stars 14 forks source link

Replaced setTimeout with requestAnimationFrame #22

Closed pwolaq closed 6 years ago

pwolaq commented 6 years ago

So I finally found some spare time and went a step further and replaced setTimeout with requestAnimationFrame as previously suggested.

I have removed delay parameter for now, but it is possible to implement it to throttle updates - please tell me what do you think about it :)

MicheleBertoli commented 6 years ago

This is awesome, thank you very much @pwolaq.

I'm happy to merge it but I was wondering how hard it is in you opinion to keep the delay prop (and avoid a breaking change).

pwolaq commented 6 years ago

I've implemented the delay prop, but also encountered some weird behaviour with tests - after I added a new test for delay prop some of the tests started to fail.

I will try to fix it tommorow.

MicheleBertoli commented 6 years ago

You are the best, @pwolaq.

pwolaq commented 6 years ago

It turns out that I had to call jest.clearAllTimers after each test in order to prevent this weird behaviour. It should be ok now.

MicheleBertoli commented 6 years ago

🙌