Skip to content

Commit 718c42a

Browse files
committed
Fix - VueUiDag - Set #free-node-label slot to be visible when #node slot is also employed
1 parent 8e1f86a commit 718c42a

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

TestingArena/ArenaVueUiDag.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ const configTheme = computed(() => ({
212212
<LocalVueUiDag :dataset="dataset" :config="config" ref="local">
213213
<!-- <template #node-label="{ node }">
214214
{{ node.label }}
215-
</template>
216-
<template #node="{ node }">
217-
<div style="width: 100%; height: 100%; border: 1px solid red; color: black">
215+
</template> -->
216+
<!-- <template #node="{ node }">
217+
<div style="width: 100%; height: 100%; border: 1px solid red; color: black;">
218218
{{ node.label }}
219219
</div>
220220
</template> -->

src/DAG/layout.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -249,29 +249,29 @@ function translateGraph(graph) {
249249
graphLabel.height = maximumY - minimumY + marginY;
250250
}
251251

252-
function assignNodeIntersects(graph) {
253-
const ENDPOINT_OFFSET = 4;
252+
function shortenPoint(point, neighborPoint, offset) {
253+
if (!offset || !neighborPoint) {
254+
return point;
255+
}
254256

255-
function shortenPoint(point, neighborPoint, offset) {
256-
if (!offset || !neighborPoint) {
257-
return point;
258-
}
257+
const deltaX = neighborPoint.x - point.x;
258+
const deltaY = neighborPoint.y - point.y;
259+
const segmentLength = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
259260

260-
const deltaX = neighborPoint.x - point.x;
261-
const deltaY = neighborPoint.y - point.y;
262-
const segmentLength = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
261+
if (!segmentLength || segmentLength <= offset) {
262+
return point;
263+
}
263264

264-
if (!segmentLength || segmentLength <= offset) {
265-
return point;
266-
}
265+
const ratio = offset / segmentLength;
267266

268-
const ratio = offset / segmentLength;
267+
return {
268+
x: point.x + deltaX * ratio,
269+
y: point.y + deltaY * ratio,
270+
};
271+
}
269272

270-
return {
271-
x: point.x + deltaX * ratio,
272-
y: point.y + deltaY * ratio,
273-
};
274-
}
273+
function assignNodeIntersects(graph) {
274+
const ENDPOINT_OFFSET = 4;
275275

276276
graph.edges().forEach(edgeObject => {
277277
const edge = graph.edge(edgeObject);

src/components/vue-ui-dag.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,10 +1004,11 @@ defineExpose({
10041004
autoOffset: true
10051005
})"
10061006
/>
1007-
<g v-if="$slots['free-node-label']">
1008-
<slot name="free-node-label" v-bind="{ node, layoutData }"/>
1009-
</g>
10101007
</template>
1008+
1009+
<g v-if="$slots['free-node-label']">
1010+
<slot name="free-node-label" v-bind="{ node, layoutData }"/>
1011+
</g>
10111012
10121013
<!-- Full `node` slot to customize the node entirely using a div -->
10131014
<foreignObject

0 commit comments

Comments
 (0)