How does window.requestAnimationFrame(draw)
work in the walking animation without draw()
being called?
Hi @n_b!
draw()
is called, in the following line:
image.onload = draw;
We don’t write the parenthses here because we don’t want the function to run immediately, only after the load event has fired. If we wrote:
image.onload = draw();
then the browser would run the function as soon as it read that code.
1 Like