@@ -6,11 +6,14 @@ import { Background } from '@vue-flow/background'
6
6
import { Controls } from ' @vue-flow/controls'
7
7
import { MiniMap } from ' @vue-flow/minimap'
8
8
9
- const elements = ref <Elements >([
9
+ const nodes = ref <Elements >([
10
10
{ id: ' 1' , type: ' input' , label: ' Node 1' , position: { x: 250 , y: 5 }, class: ' light' },
11
11
{ id: ' 2' , label: ' Node 2' , position: { x: 100 , y: 100 }, class: ' light' },
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
+ ])
15
+
16
+ const edges = ref <Elements >([
14
17
{ id: ' e1-2' , source: ' 1' , target: ' 2' , animated: true },
15
18
{ id: ' e1-3' , source: ' 1' , target: ' 3' },
16
19
])
@@ -23,7 +26,7 @@ const { onConnect, addEdges, setViewport, toObject } = useVueFlow({
23
26
onConnect (addEdges )
24
27
25
28
function updatePos() {
26
- return elements .value .forEach ((el ) => {
29
+ return nodes .value .forEach ((el ) => {
27
30
if (isNode (el )) {
28
31
el .position = {
29
32
x: Math .random () * 400 ,
@@ -40,20 +43,34 @@ function resetViewport() {
40
43
return setViewport ({ x: 0 , y: 0 , zoom: 1 })
41
44
}
42
45
function toggleclass() {
43
- return elements .value .forEach ((el ) => (el .class = el .class === ' light' ? ' dark' : ' light' ))
46
+ return nodes .value .forEach ((el ) => (el .class = el .class === ' light' ? ' dark' : ' light' ))
44
47
}
45
48
</script >
46
49
47
50
<template >
48
- <VueFlow v-model =" elements" fit-view-on-init class =" vue-flow-basic-example" >
51
+ <VueFlow
52
+ :nodes =" nodes"
53
+ :edges =" edges"
54
+ :delete-key-code =" ['Backspace', 'Delete']"
55
+ fit-view-on-init
56
+ class =" vue-flow-basic-example"
57
+ >
49
58
<Background />
50
- <MiniMap />
59
+ <MiniMap node-color = " red " :nodes = " nodes " :edges = " edges " />
51
60
<Controls />
52
61
<Panel position =" top-right" style =" display : flex ; gap : 5px " >
62
+ <input />
53
63
<button @click =" resetViewport" >reset viewport</button >
54
64
<button @click =" updatePos" >change pos</button >
55
65
<button @click =" toggleclass" >toggle class</button >
56
66
<button @click =" logToObject" >toObject</button >
57
67
</Panel >
58
68
</VueFlow >
59
69
</template >
70
+
71
+ <style >
72
+ .vue-flow__minimap {
73
+ transform : scale (75% );
74
+ transform-origin : bottom right ;
75
+ }
76
+ </style >
0 commit comments