moved words input outside words wrapper to avoid weird graphical glitches

This commit is contained in:
Miodec 2023-03-08 14:00:52 +01:00
parent 0916fa9436
commit 06d797bd99
2 changed files with 41 additions and 16 deletions

View file

@ -221,8 +221,21 @@ export function updateWordsInputPosition(initial = false): void {
return;
}
const computed = window.getComputedStyle(activeWord);
const activeWordMargin =
parseInt(computed.marginTop) + parseInt(computed.marginBottom);
const wordsWrapperTop =
(document.querySelector("#wordsWrapper") as HTMLElement | null)
?.offsetTop || 0;
if (Config.tapeMode !== "off") {
el.style.top = activeWord.offsetTop + "px";
el.style.top =
wordsWrapperTop +
activeWord.offsetHeight +
activeWordMargin * 0.25 +
-el.offsetHeight +
"px";
el.style.left = activeWord.offsetLeft + "px";
return;
}
@ -232,10 +245,22 @@ export function updateWordsInputPosition(initial = false): void {
!posUpdateLangList.some((l) => Config.language.startsWith(l))
) {
el.style.left = "0px";
el.style.top = activeWord.offsetHeight * 2 + "px";
el.style.top =
wordsWrapperTop +
activeWord.offsetHeight * 2 +
activeWordMargin * 1.5 +
-el.offsetHeight +
"px";
} else {
el.style.top = activeWord.offsetTop + "px";
el.style.left = activeWord.offsetLeft + "px";
el.style.top =
activeWord.offsetTop -
activeWordMargin +
wordsWrapperTop +
activeWord.offsetHeight +
activeWordMargin +
-el.offsetHeight +
"px";
}
}

View file

@ -113,20 +113,20 @@
<i class="fas fa-mouse-pointer"></i>
Click here or start typing to focus
</div>
<input
id="wordsInput"
class=""
tabindex="0"
type="text"
autocomplete="off"
autocapitalize="off"
autocorrect="off"
data-gramm="false"
data-gramm_editor="false"
data-enable-grammarly="false"
list="autocompleteOff"
/>
<div id="wordsWrapper" translate="no">
<input
id="wordsInput"
class=""
tabindex="0"
type="text"
autocomplete="off"
autocapitalize="off"
autocorrect="off"
data-gramm="false"
data-gramm_editor="false"
data-enable-grammarly="false"
list="autocompleteOff"
/>
<div id="paceCaret" class="default hidden"></div>
<div id="caret" class="default"></div>
<div id="words"></div>