diff --git a/kalk_web/public/index.html b/kalk_web/public/index.html
index 1445316..e9c9d71 100644
--- a/kalk_web/public/index.html
+++ b/kalk_web/public/index.html
@@ -38,6 +38,8 @@
height: 100%;
margin: 0;
padding: 0;
+ padding-top: 300px;
+ padding-bottom: 300px;
}
#wrapper {
diff --git a/kalk_web/src/KalkCalculator.svelte b/kalk_web/src/KalkCalculator.svelte
index 0b3b236..2ae7253 100644
--- a/kalk_web/src/KalkCalculator.svelte
+++ b/kalk_web/src/KalkCalculator.svelte
@@ -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) {