Nice work. I'm not a JS expert but I think I saw a bug.
Inside of animate() you are calling setTimeout() to automatically call animate repeatedly but this is also calling setTimeout() every time animate runs but setTimeout() should only be run once. You should be able to take
What you mean is setInterval and does work well for synchronous execution. His approach is correct and would even work if the animate function is asynchronous as the next tick gets scheduled at the end of animate function execution.
Comments (283) 76 threads
Show all comments
Showing thread 28 of 76
Inside of animate() you are calling setTimeout() to automatically call animate repeatedly but this is also calling setTimeout() every time animate runs but setTimeout() should only be run once.
and paste it over animate() on the last lineYou should be able to take