mirror of
https://github.com/PaddiM8/kalker.git
synced 2024-12-13 01:50:41 +01:00
kalk_web: Avoid automatic scrolling during input on phones
This commit is contained in:
parent
27d96ca3c0
commit
4b0bb9cc13
@ -38,6 +38,8 @@
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
padding-top: 300px;
|
||||
padding-bottom: 300px;
|
||||
}
|
||||
|
||||
#wrapper {
|
||||
|
@ -164,7 +164,7 @@
|
||||
}
|
||||
|
||||
function insertText(input: string) {
|
||||
inputElement.focus();
|
||||
inputElement.focus({ preventScroll: true });
|
||||
let cursorPos = getCursorPos(inputElement);
|
||||
const textContent = inputElement.textContent;
|
||||
let movementOffset = input.length;
|
||||
@ -196,8 +196,16 @@
|
||||
const [highlighted, offset] = highlight(newString);
|
||||
|
||||
inputElement.innerHTML = highlighted;
|
||||
inputElement.focus();
|
||||
inputElement.focus({ preventScroll: true });
|
||||
setCursorPos(inputElement, cursorPos - offset + movementOffset);
|
||||
|
||||
// I know this sucks, but it keeps scrolling away on some browsers >:(
|
||||
let i = 0;
|
||||
setInterval(() => {
|
||||
if (i == 60) return;
|
||||
calculatorElement.scrollIntoView();
|
||||
i++;
|
||||
}, 20);
|
||||
}
|
||||
|
||||
function focus(element: HTMLInputElement) {
|
||||
|
Loading…
Reference in New Issue
Block a user