File tree Expand file tree Collapse file tree 3 files changed +9
-19
lines changed Expand file tree Collapse file tree 3 files changed +9
-19
lines changed Original file line number Diff line number Diff line change @@ -199,10 +199,10 @@ const NodeWrapper = defineComponent({
199
199
getClass . value ,
200
200
] ,
201
201
'style' : {
202
+ visibility : node . value . initialized ? 'visible' : 'hidden' ,
202
203
zIndex : node . value . computedPosition . z ?? zIndex ( ) ,
203
204
transform : `translate(${ node . value . computedPosition . x } px,${ node . value . computedPosition . y } px)` ,
204
205
pointerEvents : props . selectable || props . draggable ? 'all' : 'none' ,
205
- visibility : node . value . initialized ? 'visible' : 'hidden' ,
206
206
...getStyle . value ,
207
207
} ,
208
208
'tabIndex' : props . focusable ? 0 : undefined ,
Original file line number Diff line number Diff line change @@ -9,24 +9,6 @@ export function useOnInitHandler() {
9
9
( isInitialized ) => {
10
10
if ( isInitialized ) {
11
11
setTimeout ( ( ) => {
12
- // todo: call these when *nodes* are initialized instead of the viewport
13
- // currently doesn't work quite right because the viewport dimensions are not yet available when the nodes are initialized
14
- if ( ! vfInstance . fitViewOnInitDone . value && vfInstance . fitViewOnInit . value ) {
15
- vfInstance . fitView ( )
16
- }
17
-
18
- vfInstance . fitViewOnInitDone . value = true
19
-
20
- // Here, we are making all nodes visible once we have the dimensions.
21
- if ( ! document . querySelector ( '#vue-flow__initialized-styles' ) ) {
22
- const style = document . createElement ( 'style' )
23
- style . id = 'vue-flow__initialized-styles'
24
- document . head . appendChild ( style )
25
-
26
- const css = `.vue-flow__node { visibility: visible !important; }`
27
- style . appendChild ( document . createTextNode ( css ) )
28
- }
29
-
30
12
vfInstance . emits . init ( vfInstance )
31
13
vfInstance . emits . paneReady ( vfInstance )
32
14
} , 1 )
Original file line number Diff line number Diff line change 1
1
import { zoomIdentity } from 'd3-zoom'
2
2
import type { ComputedRef } from 'vue'
3
+ import { nextTick } from 'vue'
3
4
import { until } from '@vueuse/core'
4
5
import type {
5
6
Actions ,
@@ -180,6 +181,13 @@ export function useActions(
180
181
return res
181
182
} , [ ] )
182
183
184
+ if ( ! state . fitViewOnInitDone && state . fitViewOnInit ) {
185
+ nextTick ( ( ) => {
186
+ viewportHelper . value . fitView ( )
187
+ state . fitViewOnInitDone = true
188
+ } )
189
+ }
190
+
183
191
if ( changes . length ) {
184
192
state . hooks . nodesChange . trigger ( changes )
185
193
}
You can’t perform that action at this time.
0 commit comments