Added scroll to top component and associated animation

This commit is contained in:
2025-01-10 12:26:41 +00:00
parent b07ca48cc4
commit aa706ca1c2
2 changed files with 34 additions and 1 deletions

View File

@@ -1,5 +1,7 @@
<script>
import "./NavigationFooter.scss";
import "../shared_components/ScrollToTop.svelte";
import ScrollToTop from "../shared_components/ScrollToTop.svelte";
</script>
<div class="navigation-footer">
@@ -37,7 +39,10 @@
</div>
</div>
<div class="navigation-footer-column-mid">
<div class="navigation-footer-return">↥↥↥ Return to top ↥↥↥</div>
<ScrollToTop
class="navigation-footer-return"
text="↥↥↥ Return to top ↥↥↥"
/>
</div>
<div class="navigation-footer-column-right">
<div class="navigation-footer-topic-column">

View File

@@ -0,0 +1,28 @@
<script>
export let text = "Return to top";
function scrollToTop() {
window.scrollTo({
top: 0,
behavior: "smooth",
});
}
function handleKeydown(event) {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
scrollToTop();
}
}
</script>
<span
class="cursor-pointer {$$props.class}"
style="cursor: pointer;"
on:click={scrollToTop}
on:keydown={handleKeydown}
tabindex="0"
role="button"
>
{text}
</span>