File tree Expand file tree Collapse file tree 1 file changed +24
-5
lines changed
apps/svelte.dev/src/routes/docs/[...path] Expand file tree Collapse file tree 1 file changed +24
-5
lines changed Original file line number Diff line number Diff line change 1
1
<script lang =" ts" >
2
2
import { afterNavigate } from ' $app/navigation' ;
3
3
import type { Document } from ' @sveltejs/site-kit' ;
4
+ import { tick } from ' svelte' ;
4
5
5
6
let { content, document }: { content: HTMLElement ; document: Document } = $props ();
6
7
7
8
let headings: NodeListOf <HTMLHeadingElement >;
8
9
let current = $state (' ' );
10
+ let element: HTMLElement ;
9
11
10
12
afterNavigate (() => {
11
13
current = location .hash .slice (1 );
26
28
next .getBoundingClientRect ().top > threshold
27
29
) {
28
30
current = heading .id ;
31
+
32
+ tick ().then (() => {
33
+ const active = element .querySelector (' .active' );
34
+ active ?.scrollIntoView ({
35
+ block: ' center'
36
+ });
37
+ });
38
+
29
39
break ;
30
40
}
31
41
}
40
50
On this page
41
51
</label >
42
52
43
- <nav >
53
+ <nav bind:this ={ element } >
44
54
<ul >
45
55
<li >
46
56
<a href ="/ {document .slug }" class:active ={current === ' ' }>
146
156
}
147
157
148
158
@media (min-width : 1200px ) {
159
+ width: calc(var(--sidebar-width) - var(--sk-page-padding-side));
160
+ padding: 0;
161
+ box-sizing : border-box ;
149
162
position: fixed;
163
+ display: flex;
164
+ flex-direction : column;
150
165
top: 14rem;
151
- right: 0;
152
- width: var(--sidebar-width);
153
- padding: 0 var(--sk-page-padding-side) 0 0;
154
- box-sizing : border-box ;
166
+ left: calc(
167
+ var(--sk-page-padding-side) + var(--sidebar-width) + var(--sk-line-max-width) +
168
+ var(--sk-page-padding-side)
169
+ );
170
+ height: calc(100vh - 20rem);
171
+ overflow: hidden;
155
172
156
173
input {
157
174
display : none ;
170
187
171
188
nav {
172
189
display : block ;
190
+ height : 100% ;
191
+ overflow-y : auto ;
173
192
174
193
li :first-child {
175
194
display: list-item ;
You can’t perform that action at this time.
0 commit comments