fix: tape mode not centering words on window resize

closes #6135
closes #6093
This commit is contained in:
Miodec 2025-01-02 14:00:04 +01:00
parent 799656dcec
commit a2f6c1f832

View file

@ -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;
@ -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;
}
@ -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;