mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-03 20:15:45 +08:00
fix(tape mode): tape jumping around when words were removed off screen
This commit is contained in:
parent
75236f1d5d
commit
2059e88b9c
1 changed files with 3 additions and 1 deletions
|
@ -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`);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue