@@ -12,15 +12,12 @@ const elements = ref<Elements>([
12
12
{ id: ' 3' , label: ' Node 3' , position: { x: 400 , y: 100 }, class: ' light' },
13
13
{ id: ' 4' , label: ' Node 4' , position: { x: 400 , y: 200 }, class: ' light' },
14
14
{ id: ' e1-2' , source: ' 1' , target: ' 2' , animated: true },
15
- { id: ' e1-3' , source: ' 1' , target: ' 3 ' },
15
+ { id: ' e1-3' , source: ' 1' , target: ' 5 ' },
16
16
])
17
- const { onNodeDragStop, onEdgeClick, onConnect, addEdges, setTransform, toObject, fitView, onPaneReady, setNodes, setEdges } =
18
- useVueFlow ({
19
- minZoom: 0.2 ,
20
- maxZoom: 4 ,
21
- connectOnClick: true ,
22
- fitViewOnInit: false ,
23
- })
17
+ const { onNodeDragStop, onEdgeClick, onConnect, addEdges, setTransform, toObject } = useVueFlow ({
18
+ minZoom: 0.2 ,
19
+ maxZoom: 4 ,
20
+ })
24
21
25
22
onNodeDragStop ((e ) => console .log (' drag stop' , e .event ))
26
23
onEdgeClick (console .log )
@@ -36,29 +33,13 @@ const updatePos = () =>
36
33
}
37
34
})
38
35
39
- onPaneReady ((instance ) => {
40
- setNodes ([
41
- { id: ' 1' , type: ' input' , label: ' Node 1' , position: { x: 250 , y: 5 }, class: ' light' },
42
- { id: ' 2' , label: ' Node 2' , position: { x: 100 , y: 100 }, class: ' light' },
43
- { id: ' 3' , label: ' Node 3' , position: { x: 400 , y: 100 }, class: ' light' },
44
- { id: ' 4' , label: ' Node 4' , position: { x: 400 , y: 200 }, class: ' light' },
45
- ])
46
-
47
- setEdges ([
48
- { id: ' e1-2' , source: ' 1' , target: ' 2' , animated: true },
49
- { id: ' e1-3' , source: ' 1' , target: ' 3' },
50
- ])
51
-
52
- instance .fitView ()
53
- })
54
-
55
36
const logToObject = () => console .log (toObject ())
56
37
const resetTransform = () => setTransform ({ x: 0 , y: 0 , zoom: 1 })
57
38
const toggleclass = () => elements .value .forEach ((el ) => (el .class = el .class === ' light' ? ' dark' : ' light' ))
58
39
</script >
59
40
60
41
<template >
61
- <VueFlow v-model =" elements" connection-mode =" strict" class =" vue-flow-basic-example" >
42
+ <VueFlow v-model =" elements" fit-view-on-init connection-mode =" strict" class =" vue-flow-basic-example" >
62
43
<Background />
63
44
<MiniMap />
64
45
<Controls />
0 commit comments