Join Nostr
2024-11-03 19:27:02 UTC
in reply to

Doug Parker 🕸️ on Nostr: `requestAnimationFrame` is tied to the refresh rate of the display (typically 16ms, ...

`requestAnimationFrame` is tied to the refresh rate of the display (typically 16ms, but that does vary).

I'd suggest immediately reacting to a mouse event in your `addEventListener` callback (or scheduling a separate "physics" update with `setTimeout`) and then updating the DOM accordingly in your `requestAnimationFrame`.

Even `setTimeout` isn't super reliable timing, so make sure to measure the actual elapsed time rather than the requested timeout.