fix(edges): connection line not showing up when no edges are defined
Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -14,8 +14,8 @@ const sourceHandle =
|
|||||||
: store.connectionHandleType && props.sourceNode.handleBounds[store.connectionHandleType ?? 'source']?.[0]
|
: store.connectionHandleType && props.sourceNode.handleBounds[store.connectionHandleType ?? 'source']?.[0]
|
||||||
const sourceHandleX = sourceHandle ? sourceHandle.x + sourceHandle.width / 2 : props.sourceNode.dimensions.width / 2
|
const sourceHandleX = sourceHandle ? sourceHandle.x + sourceHandle.width / 2 : props.sourceNode.dimensions.width / 2
|
||||||
const sourceHandleY = sourceHandle ? sourceHandle.y + sourceHandle.height / 2 : props.sourceNode.dimensions.height
|
const sourceHandleY = sourceHandle ? sourceHandle.y + sourceHandle.height / 2 : props.sourceNode.dimensions.height
|
||||||
const sourceX = props.sourceNode.position.x + sourceHandleX
|
const sourceX = props.sourceNode.computedPosition.x + sourceHandleX
|
||||||
const sourceY = props.sourceNode.position.y + sourceHandleY
|
const sourceY = props.sourceNode.computedPosition.y + sourceHandleY
|
||||||
|
|
||||||
const isRightOrLeft = sourceHandle?.position === Position.Left || sourceHandle?.position === Position.Right
|
const isRightOrLeft = sourceHandle?.position === Position.Left || sourceHandle?.position === Position.Right
|
||||||
const targetPosition = isRightOrLeft ? Position.Left : Position.Top
|
const targetPosition = isRightOrLeft ? Position.Left : Position.Top
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useHandle, useStore } from '../../composables'
|
import { useHandle, useStore } from '../../composables'
|
||||||
import { ConnectionMode, Position, EdgePositions, Dimensions, Transform, GraphEdge } from '../../types'
|
import { ConnectionMode, Position, GraphEdge } from '../../types'
|
||||||
import { isEdge, getEdgePositions, getHandle, isEdgeVisible } from '../../utils'
|
import { getEdgePositions, getHandle, getMarkerId } from '../../utils'
|
||||||
import EdgeAnchor from './EdgeAnchor.vue'
|
import EdgeAnchor from './EdgeAnchor.vue'
|
||||||
|
|
||||||
interface EdgeWrapper {
|
interface EdgeWrapper {
|
||||||
@@ -119,8 +119,8 @@ export default {
|
|||||||
labelBgBorderRadius: props.edge.labelBgBorderRadius,
|
labelBgBorderRadius: props.edge.labelBgBorderRadius,
|
||||||
data: props.edge.data,
|
data: props.edge.data,
|
||||||
style: props.edge.style,
|
style: props.edge.style,
|
||||||
markerEnd: props.edge.markerEnd,
|
markerStart: `url(#${getMarkerId(props.edge.markerStart)})`,
|
||||||
markerStart: props.edge.markerStart,
|
markerEnd: `url(#${getMarkerId(props.edge.markerEnd)})`,
|
||||||
sourcePosition,
|
sourcePosition,
|
||||||
targetPosition,
|
targetPosition,
|
||||||
sourceX: edgePos.sourceX,
|
sourceX: edgePos.sourceX,
|
||||||
@@ -150,8 +150,8 @@ export default {
|
|||||||
labelBgBorderRadius: props.edge.labelBgBorderRadius,
|
labelBgBorderRadius: props.edge.labelBgBorderRadius,
|
||||||
data: props.edge.data,
|
data: props.edge.data,
|
||||||
style: props.edge.style,
|
style: props.edge.style,
|
||||||
markerEnd: props.edge.markerEnd,
|
markerStart: `url(#${getMarkerId(props.edge.markerStart)})`,
|
||||||
markerStart: props.edge.markerStart,
|
markerEnd: `url(#${getMarkerId(props.edge.markerEnd)})`,
|
||||||
sourcePosition,
|
sourcePosition,
|
||||||
targetPosition,
|
targetPosition,
|
||||||
sourceX: edgePos.sourceX,
|
sourceX: edgePos.sourceX,
|
||||||
|
|||||||
@@ -80,10 +80,10 @@ const onDragStop: DraggableEventListener = ({ event, data: { deltaX, deltaY } })
|
|||||||
|
|
||||||
const xyzPos = computed(() => {
|
const xyzPos = computed(() => {
|
||||||
if (node.value.parentNode) {
|
if (node.value.parentNode) {
|
||||||
return getXYZPos(node.value, {
|
return (node.value.computedPosition = getXYZPos(node.value, {
|
||||||
...node.value.position,
|
...node.value.position,
|
||||||
z: node.value.computedPosition.z,
|
z: node.value.computedPosition.z,
|
||||||
})
|
}))
|
||||||
} else {
|
} else {
|
||||||
return node.value.computedPosition
|
return node.value.computedPosition
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export default {
|
|||||||
:width="store.dimensions.width"
|
:width="store.dimensions.width"
|
||||||
:height="store.dimensions.height"
|
:height="store.dimensions.height"
|
||||||
class="vue-flow__edges vue-flow__container"
|
class="vue-flow__edges vue-flow__container"
|
||||||
:style="{ zIndex: level.z }"
|
:style="`z-index: ${parseInt(level.level)}`"
|
||||||
>
|
>
|
||||||
<MarkerDefinitions v-if="level.isMaxLevel" :default-color="store.defaultMarkerColor" />
|
<MarkerDefinitions v-if="level.isMaxLevel" :default-color="store.defaultMarkerColor" />
|
||||||
<g>
|
<g>
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ export default (state: FlowState): FlowGetters => {
|
|||||||
e.targetNode.dimensions.width &&
|
e.targetNode.dimensions.width &&
|
||||||
e.targetNode.dimensions.height &&
|
e.targetNode.dimensions.height &&
|
||||||
isEdgeVisible({
|
isEdgeVisible({
|
||||||
sourcePos: e.sourceNode.position || { x: 0, y: 0 },
|
sourcePos: e.sourceNode.computedPosition || { x: 0, y: 0 },
|
||||||
targetPos: e.targetNode.position || { x: 0, y: 0 },
|
targetPos: e.targetNode.computedPosition || { x: 0, y: 0 },
|
||||||
sourceWidth: e.sourceNode.dimensions.width,
|
sourceWidth: e.sourceNode.dimensions.width,
|
||||||
sourceHeight: e.sourceNode.dimensions.height,
|
sourceHeight: e.sourceNode.dimensions.height,
|
||||||
targetWidth: e.targetNode.dimensions.width,
|
targetWidth: e.targetNode.dimensions.width,
|
||||||
|
|||||||
+1
-1
@@ -150,7 +150,7 @@ export const groupEdgesByZLevel = (edges: GraphEdge[], nodes: GraphNode[]) => {
|
|||||||
return tree
|
return tree
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
return Object.entries(levelLookup).map(([key, edges]) => {
|
return Object.entries(Object.keys(levelLookup).length ? levelLookup : { 0: [] }).map(([key, edges]) => {
|
||||||
const level = +key
|
const level = +key
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
+2
-2
@@ -335,8 +335,8 @@ export const getTransformForBounds = (
|
|||||||
export const getXYZPos = (node: GraphNode, result: XYZPosition): XYZPosition => {
|
export const getXYZPos = (node: GraphNode, result: XYZPosition): XYZPosition => {
|
||||||
if (!node.parentNode) return result
|
if (!node.parentNode) return result
|
||||||
return getXYZPos(node.parentNode, {
|
return getXYZPos(node.parentNode, {
|
||||||
x: result.x + node.parentNode.position.x,
|
x: result.x + node.parentNode.computedPosition.x,
|
||||||
y: result.y + node.parentNode.position.y,
|
y: result.y + node.parentNode.computedPosition.y,
|
||||||
z:
|
z:
|
||||||
node.parentNode.computedPosition.z > node.computedPosition.z ? node.parentNode.computedPosition.z : node.computedPosition.z,
|
node.parentNode.computedPosition.z > node.computedPosition.z ? node.parentNode.computedPosition.z : node.computedPosition.z,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user