Skip to content

Commit 69e3f80

Browse files
author
Dmitry Marov
committed
improved custom edges
1 parent f3bdd8b commit 69e3f80

1 file changed

Lines changed: 10 additions & 17 deletions

File tree

  • static/use-cases/minimal-custom-edge-shape

‎static/use-cases/minimal-custom-edge-shape/index.html‎

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,16 @@
119119
constructor(element) {
120120
this.canvas = new CanvasBuilder(element)
121121
.setDefaults({
122+
nodes: {
123+
priority: 1,
124+
},
122125
edges: {
123126
shape: () => {
124127
return new MyCustomEdgeShape();
125128
}
126129
}
127130
})
128-
.enableUserDraggableNodes()
131+
.enableUserDraggableNodes({ moveEdgesOnTop: false })
129132
.enableUserTransformableViewport()
130133
.enableBackground()
131134
.build();
@@ -137,44 +140,34 @@
137140
this.createNode({
138141
x: 200,
139142
y: 200,
140-
frontPortId: "node-1-in",
141-
backPortId: "node-1-out",
143+
portId: "port-1",
142144
}),
143145
)
144146
.addNode(
145147
this.createNode({
146148
x: 600,
147149
y: 300,
148-
frontPortId: "node-2-in",
149-
backPortId: "node-2-out",
150+
portId: "port-2",
150151
}),
151152
)
152153
.addEdge({
153-
from: "node-1-out",
154-
to: "node-2-in",
154+
from: "port-1",
155+
to: "port-2",
155156
})
156157
.focus();
157158
}
158159

159-
createNode({ x, y, frontPortId, backPortId }) {
160+
createNode({ x, y, portId }) {
160161
const node = document.createElement("div");
161-
const frontPort = document.createElement("div");
162-
const backPort = document.createElement("div");
163162

164163
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);
170164

171165
return {
172166
element: node,
173167
x: x,
174168
y: y,
175169
ports: [
176-
{ id: frontPortId, element: frontPort },
177-
{ id: backPortId, element: backPort },
170+
{ id: portId, element: node },
178171
],
179172
};
180173
}

0 commit comments

Comments
 (0)