mirror of
https://github.com/librespeed/speedtest.git
synced 2026-10-21 15:51:14 +00:00
fix: defer mobile gauge scroll until running render
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
This commit is contained in:
parent
799eaca184
commit
62190e3d63
1 changed files with 18 additions and 1 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue