You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
537 B
Svelte
23 lines
537 B
Svelte
4 years ago
|
<style>
|
||
|
</style>
|
||
|
|
||
|
<script>
|
||
|
export let href;
|
||
|
|
||
|
function click() {
|
||
|
console.log(href);
|
||
|
window.scrollTo(0, 0);
|
||
|
var element = document.getElementById(href);
|
||
|
var panel = document.querySelector(".panel");
|
||
|
var elementPosition = element.getBoundingClientRect().top;
|
||
|
var offsetPosition = elementPosition - panel.scrollHeight;
|
||
|
|
||
|
window.scrollTo({
|
||
|
top: offsetPosition,
|
||
|
behavior: "smooth"
|
||
|
});
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<span on:click|preventDefault={click}><slot></slot></span>
|