use 30fps (should help #65)

This commit is contained in:
Ashley //// 2024-02-18 20:17:47 +00:00
parent 09aab0784a
commit 866e0b853d

View file

@ -1890,10 +1890,19 @@ if (/[?&]autoplay=/.test(location.search)) {
<script>
let requestId;
let lastDrawTime = 0; // Timestamp of the last draw request
const loopStart = () => {
requestId = window.requestAnimationFrame(loopStart)
}
const now = performance.now();
const elapsed = now - lastDrawTime;
if (elapsed >= (1000 / 30)) { // Adjusted for milliseconds
lastDrawTime = now;
draw();
}
// Continue loop using requestAnimationFrame
requestId = window.requestAnimationFrame(loopStart);
};
const loopCancel = () => {
window.cancelAnimationFrame(requestId)