+ 1

How does this code work even the call to draw does not have arguments?

Code from MDN https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals let startTime = null; function draw(timestamp) { if(!startTime) { startTime = timestamp; } currentTime = timestamp - startTime; requestAnimationFrame(draw); } draw();

29th Apr 2019, 2:49 AM
Alquen
Alquen - avatar
2 ответов
+ 3
Because window.requestAnimationFrame(step) takes a callback step with timestamp set to the first augument. Check out this simple code to see how window.requestAnimationFrame(step) get the timestamp when it run. https://code.sololearn.com/WpQ8JrlfcLW7/?ref=app
29th Apr 2019, 3:09 AM
Calviղ
Calviղ - avatar
+ 1
Thanks Calviղ
29th Apr 2019, 1:16 PM
Alquen
Alquen - avatar