From 62190e3d63f7a4b27151bb571af8be068726366f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 12 Sep 2026 13:31:28 +0000 Subject: [PATCH] fix: defer mobile gauge scroll until running render Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com> --- frontend/javascript/index.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/frontend/javascript/index.js b/frontend/javascript/index.js index 72c1d2a..f1fe7d8 100644 --- a/frontend/javascript/index.js +++ b/frontend/javascript/index.js @@ -16,6 +16,8 @@ const testState = { state: INITIALIZING, speedtest: null, servers: [], + initialGaugeScrollPending: false, + initialGaugeScrollScheduled: false, selectedServerDirty: false, testData: null, testDataDirty: false, @@ -81,8 +83,8 @@ function startButtonClickHandler() { case READY: case FINISHED: testState.speedtest.start(); + testState.initialGaugeScrollPending = true; testState.state = RUNNING; - requestAnimationFrame(scrollInitialDownloadGaugeIntoView); return; case RUNNING: testState.speedtest.abort(); @@ -374,6 +376,21 @@ function startRenderingLoop() { ) ); + if ( + testState.state === RUNNING && + testState.initialGaugeScrollPending && + !testState.initialGaugeScrollScheduled + ) { + testState.initialGaugeScrollScheduled = true; + requestAnimationFrame(() => { + if (testState.state === RUNNING) { + scrollInitialDownloadGaugeIntoView(); + } + testState.initialGaugeScrollPending = false; + testState.initialGaugeScrollScheduled = false; + }); + } + // Show ping and jitter if data is available pingAndJitter.forEach((e) => e.classList.toggle(