In this code block what does requestAnimationFrame
do?
tick() {
if (this.running) {
this.remaining = Math.max(0, this.end - Date.now());
requestAnimationFrame(() => this.tick());
}
}
In other words what would be the difference between the above code an calling this.tick()
outside of the requestAnimationFrame()
:
tick() {
if (this.running) {
this.remaining = Math.max(0, this.end - Date.now());
this.tick()
}
}
For reference this code sample is from the What is Lit web component timer example.