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,11 +1890,20 @@ if (/[?&]autoplay=/.test(location.search)) {
<script> <script>
let requestId; let requestId;
let lastDrawTime = 0; // Timestamp of the last draw request
const loopStart = () => { 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 = () => { const loopCancel = () => {
window.cancelAnimationFrame(requestId) window.cancelAnimationFrame(requestId)
requestId = undefined requestId = undefined