From 89849f4eacd60614af7dddf50fb029dd1e30b61a Mon Sep 17 00:00:00 2001
From: Braks <78412429+bcakmakoglu@users.noreply.github.com>
Date: Wed, 24 Nov 2021 10:44:06 +0100
Subject: [PATCH] update(connection): pass source node to ConnectionLine as
prop
Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
---
examples/Provider/Sidebar.vue | 4 ++--
.../ConnectionLine/ConnectionLine.vue | 20 +++++++++----------
src/container/EdgeRenderer/EdgeRenderer.vue | 2 +-
3 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/examples/Provider/Sidebar.vue b/examples/Provider/Sidebar.vue
index fa81ef79..34505daa 100644
--- a/examples/Provider/Sidebar.vue
+++ b/examples/Provider/Sidebar.vue
@@ -2,7 +2,7 @@
import { useVueFlow } from '~/index'
const store = useVueFlow()
-const nodes = computed(() => store.nodes)
+const nodes = computed(() => store.getNodes)
const transform = computed(() => store.transform)
const selectAll = () => {
@@ -19,7 +19,7 @@ const selectAll = () => {
{{ [transform[0].toFixed(2), transform[1].toFixed(2), transform[2].toFixed(2)] }}
Nodes
- Node {{ node.id }} - x: {{ node.__vf.position.x.toFixed(2) }}, y: {{ node.__vf.position.y.toFixed(2) }}
+ Node {{ node.id }} - x: {{ node.position.x.toFixed(2) }}, y: {{ node.position.y.toFixed(2) }}
diff --git a/src/components/ConnectionLine/ConnectionLine.vue b/src/components/ConnectionLine/ConnectionLine.vue
index d5bdaa75..4b957235 100644
--- a/src/components/ConnectionLine/ConnectionLine.vue
+++ b/src/components/ConnectionLine/ConnectionLine.vue
@@ -9,13 +9,12 @@ import {
HandleType,
XYPosition,
ConnectionMode,
- VFInternals,
Transform,
GraphNode,
} from '../../types'
interface ConnectionLineProps {
- vf: VFInternals
+ sourceNode: GraphNode
connectionLineType?: ConnectionLineType
connectionLineStyle?: CSSProperties
connectionHandleId?: ElementId
@@ -33,15 +32,16 @@ const props = withDefaults(defineProps(), {
connectionPosition: () => ({ x: 0, y: 0 }),
})
-const sourceNode = props.nodes.find((n) => n.id === props.connectionNodeId)
const sourceHandle =
props.connectionHandleId && props.connectionHandleType
- ? props.vf.handleBounds[props.connectionHandleType]?.find((d: HandleElement) => d.id === props.connectionHandleId)
- : props.connectionHandleType && props.vf.handleBounds[props.connectionHandleType ?? 'source']?.[0]
-const sourceHandleX = sourceHandle ? sourceHandle.x + sourceHandle.width / 2 : (props.vf.width as number) / 2
-const sourceHandleY = sourceHandle ? sourceHandle.y + sourceHandle.height / 2 : props.vf.height
-const sourceX = props.vf.position.x + sourceHandleX
-const sourceY = props.vf.position.y + sourceHandleY
+ ? props.sourceNode.__vf.handleBounds[props.connectionHandleType]?.find(
+ (d: HandleElement) => d.id === props.connectionHandleId,
+ )
+ : props.connectionHandleType && props.sourceNode.__vf.handleBounds[props.connectionHandleType ?? 'source']?.[0]
+const sourceHandleX = sourceHandle ? sourceHandle.x + sourceHandle.width / 2 : (props.sourceNode.__vf.width as number) / 2
+const sourceHandleY = sourceHandle ? sourceHandle.y + sourceHandle.height / 2 : props.sourceNode.__vf.height
+const sourceX = props.sourceNode.position.x + sourceHandleX
+const sourceY = props.sourceNode.position.y + sourceHandleY
const isRightOrLeft = sourceHandle?.position === Position.Left || sourceHandle?.position === Position.Right
const targetPosition = isRightOrLeft ? Position.Left : Position.Top
@@ -105,7 +105,7 @@ export default {
connectionLineType: props.connectionLineType,
connectionLineStyle: props.connectionLineStyle,
nodes: props.nodes,
- sourceNode,
+ sourceNode: props.sourceNode,
sourceHandle,
}"
>
diff --git a/src/container/EdgeRenderer/EdgeRenderer.vue b/src/container/EdgeRenderer/EdgeRenderer.vue
index b0ac21b4..a296b215 100644
--- a/src/container/EdgeRenderer/EdgeRenderer.vue
+++ b/src/container/EdgeRenderer/EdgeRenderer.vue
@@ -95,7 +95,7 @@ export default {