diff --git a/src/routes/calculator/index.svelte b/src/routes/calculator/index.svelte index be019bed..62645bc0 100644 --- a/src/routes/calculator/index.svelte +++ b/src/routes/calculator/index.svelte @@ -16,6 +16,7 @@ let weaponCalc; let characterCalc; + let resinCalc; function openHowTo() { openModal( @@ -28,16 +29,22 @@ ); } - export function scroll(type) { - const elementPosition = - type === 'character' ? characterCalc.getBoundingClientRect().top : weaponCalc.getBoundingClientRect().top; - const headerOffset = 80; - const offsetPosition = elementPosition - headerOffset; + export function findPos(id) { + let node = document.getElementById(id); + let curtop = 0; + let curtopscroll = 0; + let headerOffset = 40; + if (node.offsetParent) { + do { + curtop += node.offsetTop; + curtopscroll += node.offsetParent ? node.offsetParent.scrollTop : 0; + } while ((node = node.offsetParent)); - window.scrollTo({ - top: offsetPosition, - behavior: 'smooth', - }); + window.scrollTo({ + top: curtop - curtopscroll - headerOffset, + behavior: 'smooth', + }); + } } @@ -60,14 +67,15 @@
- +

@@ -76,14 +84,19 @@

- +

@@ -91,7 +104,15 @@

-
+
+