minor adjustments
This commit is contained in:
@@ -126,7 +126,16 @@
|
||||
return new Promise((resolve) => setTimeout(resolve, FADE_OUT_MS));
|
||||
});
|
||||
|
||||
afterNavigate(() => {
|
||||
let mainEl = $state<HTMLElement | null>(null);
|
||||
|
||||
afterNavigate((navigation) => {
|
||||
// The page scrolls inside <main>, not the window, so SvelteKit's own scroll
|
||||
// handling never touches it and a new page would open half way down.
|
||||
// Back/forward and in-page anchors keep their position.
|
||||
if (navigation.type !== 'popstate' && !navigation.to?.url.hash) {
|
||||
mainEl?.scrollTo({ top: 0 });
|
||||
}
|
||||
|
||||
if (typeof document.startViewTransition === 'function' || reducedMotion()) {
|
||||
contentVisible = true;
|
||||
return;
|
||||
@@ -202,6 +211,7 @@
|
||||
flex-col + flex-1 below keeps the footer on the bottom edge even when
|
||||
the page is too short to fill the viewport. -->
|
||||
<main
|
||||
bind:this={mainEl}
|
||||
class={fullBleed
|
||||
? 'flex-1 overflow-hidden'
|
||||
: 'flex flex-1 flex-col overflow-y-auto p-3 lg:px-8 lg:py-6'}
|
||||
|
||||
Reference in New Issue
Block a user