File tree Expand file tree Collapse file tree 2 files changed +19
-11
lines changed
src/routes/tutorial/[slug] Expand file tree Collapse file tree 2 files changed +19
-11
lines changed Original file line number Diff line number Diff line change 123123 history .pushState ({}, ' ' , ` ?${ q} ` );
124124 }
125125 }
126+
127+ /** @type {HTMLElement} */
128+ let sidebar;
129+
130+ /** @type {import('./$types').Snapshot<number>} */
131+ export const snapshot = {
132+ capture : () => {
133+ const scroll = sidebar .scrollTop ;
134+ sidebar .scrollTop = 0 ;
135+ return scroll;
136+ },
137+ restore : (scroll ) => {
138+ sidebar .scrollTop = scroll;
139+ }
140+ };
126141< / script>
127142
128143< svelte: head>
164179 < SplitPane id= " main" type= " horizontal" min= " 360px" max= " 50%" pos= " 33%" >
165180 < section slot= " a" class = " content" >
166181 < Sidebar
182+ bind: sidebar
167183 index= {data .index }
168184 exercise= {data .exercise }
169185 on: select= {(e ) => {
Original file line number Diff line number Diff line change 11<script >
22 import { createEventDispatcher } from ' svelte' ;
3- import { afterNavigate } from ' $app/navigation' ;
43 import Modal from ' $lib/components/Modal.svelte' ;
54 import Menu from ' ./Menu.svelte' ;
65
109 /** @type {import('$lib/types').Exercise} */
1110 export let exercise;
1211
12+ /** @type {HTMLElement} */
13+ export let sidebar;
14+
1315 const dispatch = createEventDispatcher ();
1416
1517 const namespace = ' learn.svelte.dev' ;
1618 const copy_enabled = ` ${ namespace} :copy_enabled` ;
1719
18- /** @type {HTMLElement} */
19- let sidebar;
20-
2120 let show_modal = false ;
22-
23- afterNavigate (async () => {
24- // TODO ideally we would associate scroll state with
25- // history. That's a little tricky to do right now,
26- // so for now just always reset sidebar scroll
27- sidebar .scrollTop = 0 ;
28- });
2921 </script >
3022
3123<Menu {index } current ={exercise } />
You can’t perform that action at this time.
0 commit comments