Skip to content

Commit 6aca612

Browse files
authored
site: fix scroll restoration (#9222)
1 parent 408ab77 commit 6aca612

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

sites/svelte.dev/src/routes/+layout.svelte

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@
77
import '@sveltejs/site-kit/styles/index.css';
88
99
export let data;
10+
11+
/** @type {import('@sveltejs/kit').Snapshot<number>} */
12+
let shell_snapshot;
13+
14+
export const snapshot = {
15+
capture() {
16+
return {
17+
shell: shell_snapshot?.capture()
18+
};
19+
},
20+
restore(data) {
21+
shell_snapshot?.restore(data.shell);
22+
}
23+
};
1024
</script>
1125
1226
<svelte:head>
@@ -18,7 +32,7 @@
1832
</svelte:head>
1933
2034
<div style:display={$page.url.pathname !== '/docs' ? 'contents' : 'none'}>
21-
<Shell nav_visible={$page.url.pathname !== '/repl/embed'}>
35+
<Shell nav_visible={$page.url.pathname !== '/repl/embed'} bind:snapshot={shell_snapshot}>
2236
<Nav slot="top-nav" title={data.nav_title} links={data.nav_links}>
2337
<svelte:fragment slot="home-large">
2438
<strong>svelte</strong>.dev

0 commit comments

Comments
 (0)