fix(tape mode): tape jumping around when words were removed off screen

This commit is contained in:
Miodec 2025-04-01 09:49:47 +02:00
parent 75236f1d5d
commit 2059e88b9c

View file

@ -928,7 +928,7 @@ export function scrollTape(): void {
return;
}
const wordIndex = TestState.activeWordIndex - activeWordElementOffset;
let wordIndex = TestState.activeWordIndex - activeWordElementOffset;
const wordsWrapperWidth = (
document.querySelector("#wordsWrapper") as HTMLElement
).offsetWidth;
@ -951,6 +951,8 @@ export function scrollTape(): void {
activeWordElementOffset += toHide.length;
toHide.forEach((e) => e.remove());
fullWordsWidth -= widthToHide;
//need to redefine wordIndex after removing words
wordIndex = TestState.activeWordIndex - activeWordElementOffset;
const currentMargin = parseInt($("#words").css("margin-left"), 10);
$("#words").css("margin-left", `${currentMargin + widthToHide}px`);
}