Skip to content

Commit a2f6c1f

Browse files
committed
fix: tape mode not centering words on window resize
closes monkeytypegame#6135 closes monkeytypegame#6093
1 parent 799656d commit a2f6c1f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

frontend/src/ts/test/test-ui.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
} from "@monkeytype/contracts/schemas/configs";
3232
import { convertRemToPixels } from "../utils/numbers";
3333
import { getActiveFunboxes } from "./funbox/list";
34+
import * as TestState from "./test-state";
3435

3536
async function gethtml2canvas(): Promise<typeof import("html2canvas").default> {
3637
return (await import("html2canvas")).default;
@@ -469,7 +470,7 @@ export async function updateWordsInputPosition(initial = false): Promise<void> {
469470

470471
if (Config.tapeMode !== "off") {
471472
el.style.top = targetTop + "px";
472-
el.style.left = activeWord.offsetLeft + "px";
473+
el.style.left = "50%";
473474
return;
474475
}
475476

@@ -938,6 +939,19 @@ export async function updateActiveWordLetters(
938939

939940
export function scrollTape(): void {
940941
if (ActivePage.get() !== "test" || resultVisible) return;
942+
943+
if (!TestState.isActive) {
944+
$("#words")
945+
.stop(true, false)
946+
.animate(
947+
{
948+
marginLeft: "50%",
949+
},
950+
SlowTimer.get() ? 0 : 125
951+
);
952+
return;
953+
}
954+
941955
const wordsWrapperWidth = (
942956
document.querySelector("#wordsWrapper") as HTMLElement
943957
).offsetWidth;

0 commit comments

Comments
 (0)