Skip to content

Commit

Permalink
site: fix scroll restoration (sveltejs#9222)
Browse files Browse the repository at this point in the history
  • Loading branch information
PuruVJ authored and kelvinsjk committed Oct 19, 2023
1 parent c000841 commit 558c8d5
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion sites/svelte.dev/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
import '@sveltejs/site-kit/styles/index.css';
export let data;
/** @type {import('@sveltejs/kit').Snapshot<number>} */
let shell_snapshot;
export const snapshot = {
capture() {
return {
shell: shell_snapshot?.capture()
};
},
restore(data) {
shell_snapshot?.restore(data.shell);
}
};
</script>
<svelte:head>
Expand All @@ -18,7 +32,7 @@
</svelte:head>
<div style:display={$page.url.pathname !== '/docs' ? 'contents' : 'none'}>
<Shell nav_visible={$page.url.pathname !== '/repl/embed'}>
<Shell nav_visible={$page.url.pathname !== '/repl/embed'} bind:snapshot={shell_snapshot}>
<Nav slot="top-nav" title={data.nav_title} links={data.nav_links}>
<svelte:fragment slot="home-large">
<strong>svelte</strong>.dev
Expand Down

0 comments on commit 558c8d5

Please sign in to comment.