mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-09-10 08:37:24 +08:00
refactor: zen mode empty word appending
this also fixes some jumpiness when show all lines is enabled
This commit is contained in:
parent
f7666ab8e3
commit
c55901efef
2 changed files with 13 additions and 20 deletions
|
@ -190,11 +190,6 @@ async function handleSpace(): Promise<void> {
|
|||
return;
|
||||
}
|
||||
|
||||
if (Config.mode === "zen") {
|
||||
$("#words .word.active").removeClass("active");
|
||||
$("#words").append("<div class='word active'></div>");
|
||||
}
|
||||
|
||||
const currentWord: string = TestWords.words.getCurrent();
|
||||
|
||||
for (const fb of getActiveFunboxesWithFunction("handleSpace")) {
|
||||
|
@ -321,21 +316,14 @@ async function handleSpace(): Promise<void> {
|
|||
) {
|
||||
TimerProgress.update();
|
||||
}
|
||||
if (
|
||||
Config.mode === "time" ||
|
||||
Config.mode === "words" ||
|
||||
Config.mode === "custom" ||
|
||||
Config.mode === "quote"
|
||||
) {
|
||||
if (isLastWord) {
|
||||
awaitingNextWord = true;
|
||||
Loader.show();
|
||||
await TestLogic.addWord();
|
||||
Loader.hide();
|
||||
awaitingNextWord = false;
|
||||
} else {
|
||||
void TestLogic.addWord();
|
||||
}
|
||||
if (isLastWord) {
|
||||
awaitingNextWord = true;
|
||||
Loader.show();
|
||||
await TestLogic.addWord();
|
||||
Loader.hide();
|
||||
awaitingNextWord = false;
|
||||
} else {
|
||||
void TestLogic.addWord();
|
||||
}
|
||||
TestUI.updateActiveElement();
|
||||
void Caret.updatePosition();
|
||||
|
|
|
@ -550,6 +550,11 @@ export function areAllTestWordsGenerated(): boolean {
|
|||
|
||||
//add word during the test
|
||||
export async function addWord(): Promise<void> {
|
||||
if (Config.mode === "zen") {
|
||||
TestUI.appendEmptyWordElement();
|
||||
return;
|
||||
}
|
||||
|
||||
let bound = 100; // how many extra words to aim for AFTER the current word
|
||||
const funboxToPush = getActiveFunboxes()
|
||||
.find((f) => f.properties?.find((fp) => fp.startsWith("toPush")))
|
||||
|
|
Loading…
Add table
Reference in a new issue