mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-11 16:24:12 +08:00
Fixed caret not moving properly in zen mode
This commit is contained in:
parent
f2f0141bf7
commit
e22ee7d1a0
1 changed files with 10 additions and 1 deletions
|
@ -1498,6 +1498,12 @@ function updateCaretPosition() {
|
|||
currentLetterIndex = 0;
|
||||
}
|
||||
try {
|
||||
//insert temporary character so the caret will work in zen mode
|
||||
let activeWordEmpty = $("#words .active").children().length == 0;
|
||||
if (activeWordEmpty) {
|
||||
$("#words .active").append('<letter style="opacity: 0;">_</letter>');
|
||||
}
|
||||
|
||||
let currentWordNodeList = document
|
||||
.querySelector("#words .active")
|
||||
.querySelectorAll("letter");
|
||||
|
@ -1506,7 +1512,7 @@ function updateCaretPosition() {
|
|||
currentLetter = currentWordNodeList[currentWordNodeList.length - 1];
|
||||
}
|
||||
|
||||
if ($(currentLetter).length == 0) return;
|
||||
if (config.mode != "zen" && $(currentLetter).length == 0) return;
|
||||
const isLanguageLeftToRight = Misc.getCurrentLanguage().leftToRight;
|
||||
let currentLetterPosLeft = isLanguageLeftToRight
|
||||
? currentLetter.offsetLeft
|
||||
|
@ -1561,6 +1567,9 @@ function updateCaretPosition() {
|
|||
});
|
||||
}
|
||||
}
|
||||
if (activeWordEmpty) {
|
||||
$("#words .active").children().remove();
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("could not move caret: " + e.message);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue