You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
400 B

  1. <script lang="ts">
  2. import { onMount } from "svelte";
  3. export let id = "";
  4. let linkHook: HTMLElement;
  5. onMount(() => {
  6. if (window.location.hash === "#" + id) {
  7. window.scrollTo({top: linkHook.getBoundingClientRect().top});
  8. }
  9. });
  10. </script>
  11. <div class="link-hook" id={id} bind:this={linkHook}></div>
  12. <style>
  13. div.link-hook {
  14. position: relative;
  15. top: -2em;
  16. }
  17. </style>