Skip to content

Commit

Permalink
fix: tape mode not centering words on window resize
Browse files Browse the repository at this point in the history
closes #6135
closes #6093
  • Loading branch information
Miodec committed Jan 2, 2025
1 parent 799656d commit a2f6c1f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion frontend/src/ts/test/test-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof import("html2canvas").default> {
return (await import("html2canvas")).default;
Expand Down Expand Up @@ -469,7 +470,7 @@ export async function updateWordsInputPosition(initial = false): Promise<void> {

if (Config.tapeMode !== "off") {
el.style.top = targetTop + "px";
el.style.left = activeWord.offsetLeft + "px";
el.style.left = "50%";
return;
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a2f6c1f

Please sign in to comment.