diff options
Diffstat (limited to 'site')
| -rw-r--r-- | site/main.mjs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/site/main.mjs b/site/main.mjs index b5bd16c..46fea5f 100644 --- a/site/main.mjs +++ b/site/main.mjs @@ -161,6 +161,7 @@ function loadForth(taintedPath) { } async function loaded() { + const canvas = document.querySelector(CANVAS_SELECTOR); const roboWorker = new Worker('robo.mjs', { type: 'module' }); const robo = { worker: roboWorker, @@ -203,7 +204,6 @@ async function loaded() { robo.lastTick = document.timeline.currentTime; - const canvas = document.querySelector(CANVAS_SELECTOR); const [x, y] = clamp(25, robo.x + robo.speedx, robo.y + robo.speedy, canvas.width, canvas.height); robo.x = x; robo.y = y; @@ -263,13 +263,11 @@ async function loaded() { console.debug('blinken clicked', e); let lastTime = 0; - function r(t, manual=false) { + function renderFrame(t) { if (!blinkenRun) { return; } - if (!manual) { - window.requestAnimationFrame(r); - } + window.requestAnimationFrame(renderFrame); // we often get called with the same time stamp many times // in a row due to fingerprint-reduction tech. @@ -286,7 +284,7 @@ async function loaded() { blinkenRun = !blinkenRun; if (blinkenRun) { e.target.textContent = 'haltenblinken'; - r(document.timeline.currentTime); + renderFrame(document.timeline.currentTime); } else { e.target.textContent = 'blinken'; } |
