mirror of
https://github.com/PaddiM8/kalker.git
synced 2025-01-19 03:38:13 +01:00
kalk_web: Avoid automatic scrolling during input on phones
This commit is contained in:
parent
8015993907
commit
910b5a425f
@ -38,6 +38,8 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
padding-top: 300px;
|
||||||
|
padding-bottom: 300px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#wrapper {
|
#wrapper {
|
||||||
|
@ -164,7 +164,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function insertText(input: string) {
|
function insertText(input: string) {
|
||||||
inputElement.focus();
|
inputElement.focus({ preventScroll: true });
|
||||||
let cursorPos = getCursorPos(inputElement);
|
let cursorPos = getCursorPos(inputElement);
|
||||||
const textContent = inputElement.textContent;
|
const textContent = inputElement.textContent;
|
||||||
let movementOffset = input.length;
|
let movementOffset = input.length;
|
||||||
@ -196,8 +196,16 @@
|
|||||||
const [highlighted, offset] = highlight(newString);
|
const [highlighted, offset] = highlight(newString);
|
||||||
|
|
||||||
inputElement.innerHTML = highlighted;
|
inputElement.innerHTML = highlighted;
|
||||||
inputElement.focus();
|
inputElement.focus({ preventScroll: true });
|
||||||
setCursorPos(inputElement, cursorPos - offset + movementOffset);
|
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) {
|
function focus(element: HTMLInputElement) {
|
||||||
|
Loading…
Reference in New Issue
Block a user