File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
apps/svelte.dev/src/routes/docs/[topic]/[...path] Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 10
10
afterNavigate (() => {
11
11
current = location .hash .slice (1 );
12
12
headings = content .querySelectorAll (' h2' );
13
- update (); // Ensure active link is set correctly on navigation
13
+ setTimeout (() => update (), 0 ) ; // Delay to allow layout to settle
14
14
});
15
15
16
16
// Update function to activate the correct section link
17
17
function update() {
18
18
const threshold = (innerHeight * 1 ) / 3 ;
19
+
20
+ // If scrolled less than threshold, activate the page title
21
+ if (scrollY < threshold ) {
22
+ current = ' ' ;
23
+ return ;
24
+ }
25
+
19
26
let found = false ;
20
27
21
28
for (let i = 0 ; i < headings .length ; i ++ ) {
33
40
}
34
41
}
35
42
36
- // Handle case when scrolled to the top of the page
37
- if (! found && scrollY === 0 ) {
38
- current = ' ' ;
39
- }
43
+ // If no heading found, keep current as is
40
44
}
41
45
</script >
42
46
You can’t perform that action at this time.
0 commit comments