File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 17
17
import { background } from ' $lib/runtime.svelte' ;
18
18
import { app , visibility } from ' $lib/state.svelte' ;
19
19
20
+ let container = $state <undefined | HTMLElement >();
21
+
20
22
$effect (() => {
21
23
if (app .selected ) {
22
24
background .send (' bridge::ext/select' , app .selected .id );
25
27
while ((current = current .parent )) {
26
28
current .expanded = true ;
27
29
}
30
+
31
+ // scroll selected node into view
32
+ if (app .selected .dom && container ) {
33
+ const { top : start, height } = container .getBoundingClientRect ();
34
+ const top = app .selected .dom .getBoundingClientRect ().top - start<
B3F4
/span>;
35
+ if (top >= 0 && top + 24 <= height ) return ; // node is in view
36
+ app .selected .dom .scrollIntoView ({
37
+ block: top < 0 || height / 2 - top >= 0 ? ' start' : ' end' ,
38
+ });
39
+ }
28
40
} else if (app .root .length ) {
29
41
app .selected = app .root [0 ];
30
42
}
115
127
</Button >
116
128
</Toolbar >
117
129
118
- <ul on:mousemove |self ={reset } onmouseleave ={reset }>
130
+ <ul bind:this ={ container } on:mousemove |self ={reset } onmouseleave ={reset }>
119
131
{#each app .root as node (node .id )}
120
132
<Node {node } />
121
133
{/each }
You can’t perform that action at this time.
0 commit comments