mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-12-11 22:06:41 +08:00
fix(caret): incorrect vertical position if word wrapped to the next line
This commit is contained in:
parent
2908331bff
commit
02fcad4a8b
1 changed files with 6 additions and 1 deletions
|
|
@ -177,6 +177,7 @@ export async function updatePosition(noAnim = false): Promise<void> {
|
|||
if (!currentWordNodeList?.length) return;
|
||||
|
||||
const currentLetter = currentWordNodeList[inputLen];
|
||||
const lastInputLetter = currentWordNodeList[inputLen - 1];
|
||||
const lastWordLetter = currentWordNodeList[wordLen - 1];
|
||||
|
||||
const currentLanguage = await JSONData.getCurrentLanguage(Config.language);
|
||||
|
|
@ -187,11 +188,15 @@ export async function updatePosition(noAnim = false): Promise<void> {
|
|||
// so is offsetTop (for same line letters)
|
||||
const letterHeight =
|
||||
(safeNumber(currentLetter?.offsetHeight) ?? 0) ||
|
||||
(safeNumber(lastInputLetter?.offsetHeight) ?? 0) ||
|
||||
(safeNumber(lastWordLetter?.offsetHeight) ?? 0) ||
|
||||
Config.fontSize * convertRemToPixels(1);
|
||||
|
||||
const letterPosTop =
|
||||
currentLetter?.offsetTop ?? lastWordLetter?.offsetTop ?? 0;
|
||||
currentLetter?.offsetTop ??
|
||||
lastInputLetter?.offsetTop ??
|
||||
lastWordLetter?.offsetTop ??
|
||||
0;
|
||||
const diff = letterHeight - caretHeight;
|
||||
let newTop = activeWordEl.offsetTop + letterPosTop + diff / 2;
|
||||
if (Config.caretStyle === "underline") {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue