#199 scroll-up on page change

This commit is contained in:
neil 2023-02-14 14:04:49 +08:00
parent 26ff496eba
commit 75dc0d983c

View file

@ -1,7 +1,7 @@
<script lang="ts">
import '$appcss';
// import { navigating } from '$app/stores';
// import { afterNavigate } from '$app/navigation';
import { navigating } from '$app/stores';
import { afterNavigate } from '$app/navigation';
import TopBar from '$components/TopBar/TopBar.svelte';
import FooterLinks from '$components/FooterLinks/FooterLinks.svelte';
import { navStore } from '$libs/stores';
@ -10,15 +10,15 @@
let view: HTMLElement;
// $: if ($navigating) view.scrollTop = 0;
$: if ($navigating) view.scrollTop = 0;
// afterNavigate(({ from, to }) => {
// if (to && to?.route.id && from && from?.url) {
// const nextPath = to.url.href.replace(to.url.origin, '');
// const fromPath = from?.url.href.replace(from.url.origin, '');
// navStore.setNewPath(nextPath, fromPath || '/');
// }
// });
afterNavigate(({ from, to }) => {
if (to && to?.route.id && from && from?.url) {
const nextPath = to.url.href.replace(to.url.origin, '');
const fromPath = from?.url.href.replace(from.url.origin, '');
navStore.setNewPath(nextPath, fromPath || '/');
}
});
</script>
<div id="main-layout" class="w-full">
@ -31,7 +31,7 @@
<footer class="border-gray mt-8 w-full border border-r-0 bg-black">
<FooterLinks />
</footer>
<!-- <SearchPopupResults /> -->
<SearchPopupResults />
</section>
</div>