I have elements in the dom and I draw certain overlays using a canvas.
The problem is that often the render of the dom happens before the canvas is updated and therefore they are not in sync:
Is there any way to make sure the canvas is updated after a scroll before the browser does a repaint?
Not sure on the specifics how the browser handles this, but p5.js uses requestAnimationFrame for updates AFAIK and with that the browser is in control as to when the update really happens. Here’s some info on requestAnimationFrame: https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame.
Is there no way to do the overlay with CSS? If it only renders borders…