From a2f6c1f8329e50d626e99bd4b81ef9573b4fdc4c Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 2 Jan 2025 14:00:04 +0100 Subject: [PATCH] fix: tape mode not centering words on window resize closes #6135 closes #6093 --- frontend/src/ts/test/test-ui.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/src/ts/test/test-ui.ts b/frontend/src/ts/test/test-ui.ts index 542dd3afb5c1..7a04b3a8fc39 100644 --- a/frontend/src/ts/test/test-ui.ts +++ b/frontend/src/ts/test/test-ui.ts @@ -31,6 +31,7 @@ import { } from "@monkeytype/contracts/schemas/configs"; import { convertRemToPixels } from "../utils/numbers"; import { getActiveFunboxes } from "./funbox/list"; +import * as TestState from "./test-state"; async function gethtml2canvas(): Promise { return (await import("html2canvas")).default; @@ -469,7 +470,7 @@ export async function updateWordsInputPosition(initial = false): Promise { if (Config.tapeMode !== "off") { el.style.top = targetTop + "px"; - el.style.left = activeWord.offsetLeft + "px"; + el.style.left = "50%"; return; } @@ -938,6 +939,19 @@ export async function updateActiveWordLetters( export function scrollTape(): void { if (ActivePage.get() !== "test" || resultVisible) return; + + if (!TestState.isActive) { + $("#words") + .stop(true, false) + .animate( + { + marginLeft: "50%", + }, + SlowTimer.get() ? 0 : 125 + ); + return; + } + const wordsWrapperWidth = ( document.querySelector("#wordsWrapper") as HTMLElement ).offsetWidth;