|
119 | 119 | constructor(element) { |
120 | 120 | this.canvas = new CanvasBuilder(element) |
121 | 121 | .setDefaults({ |
| 122 | + nodes: { |
| 123 | + priority: 1, |
| 124 | + }, |
122 | 125 | edges: { |
123 | 126 | shape: () => { |
124 | 127 | return new MyCustomEdgeShape(); |
125 | 128 | } |
126 | 129 | } |
127 | 130 | }) |
128 | | - .enableUserDraggableNodes() |
| 131 | + .enableUserDraggableNodes({ moveEdgesOnTop: false }) |
129 | 132 | .enableUserTransformableViewport() |
130 | 133 | .enableBackground() |
131 | 134 | .build(); |
|
137 | 140 | this.createNode({ |
138 | 141 | x: 200, |
139 | 142 | y: 200, |
140 | | - frontPortId: "node-1-in", |
141 | | - backPortId: "node-1-out", |
| 143 | + portId: "port-1", |
142 | 144 | }), |
143 | 145 | ) |
144 | 146 | .addNode( |
145 | 147 | this.createNode({ |
146 | 148 | x: 600, |
147 | 149 | y: 300, |
148 | | - frontPortId: "node-2-in", |
149 | | - backPortId: "node-2-out", |
| 150 | + portId: "port-2", |
150 | 151 | }), |
151 | 152 | ) |
152 | 153 | .addEdge({ |
153 | | - from: "node-1-out", |
154 | | - to: "node-2-in", |
| 154 | + from: "port-1", |
| 155 | + to: "port-2", |
155 | 156 | }) |
156 | 157 | .focus(); |
157 | 158 | } |
158 | 159 |
|
159 | | - createNode({ x, y, frontPortId, backPortId }) { |
| 160 | + createNode({ x, y, portId }) { |
160 | 161 | const node = document.createElement("div"); |
161 | | - const frontPort = document.createElement("div"); |
162 | | - const backPort = document.createElement("div"); |
163 | 162 |
|
164 | 163 | node.classList.add("node"); |
165 | | - frontPort.classList.add("node-port"); |
166 | | - backPort.classList.add("node-port"); |
167 | | - |
168 | | - node.appendChild(frontPort); |
169 | | - node.appendChild(backPort); |
170 | 164 |
|
171 | 165 | return { |
172 | 166 | element: node, |
173 | 167 | x: x, |
174 | 168 | y: y, |
175 | 169 | ports: [ |
176 | | - { id: frontPortId, element: frontPort }, |
177 | | - { id: backPortId, element: backPort }, |
| 170 | + { id: portId, element: node }, |
178 | 171 | ], |
179 | 172 | }; |
180 | 173 | } |
|
0 commit comments