From b9bb3cfb1a64f7b8ff2059c4d50573c96e8af327 Mon Sep 17 00:00:00 2001 From: Braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Mon, 22 Nov 2021 17:14:57 +0100 Subject: [PATCH] update(types): remove null types and use undefined Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com> --- src/components/Edges/EdgeWrapper.vue | 23 ++++++++++++++++++----- src/container/VueFlow/VueFlow.vue | 2 ++ src/types/components.ts | 6 +++--- src/types/connection.ts | 8 ++++---- src/types/edge.ts | 4 ++-- src/types/node.ts | 4 ++-- src/utils/edge.ts | 4 ++-- src/utils/graph.ts | 8 ++++---- src/utils/node.ts | 6 +++--- 9 files changed, 40 insertions(+), 25 deletions(-) diff --git a/src/components/Edges/EdgeWrapper.vue b/src/components/Edges/EdgeWrapper.vue index 743fafef..ca14ddd8 100644 --- a/src/components/Edges/EdgeWrapper.vue +++ b/src/components/Edges/EdgeWrapper.vue @@ -10,8 +10,9 @@ import { SourceTargetNode, Position, FlowEvents, + EdgePositions, } from '../../types' -import { isEdge, getEdgePositions, getHandle } from '../../utils' +import { isEdge, getEdgePositions, getHandle, isEdgeVisible } from '../../utils' import EdgeAnchor from './EdgeAnchor.vue' interface EdgeWrapper { @@ -22,8 +23,8 @@ interface EdgeWrapper { component?: any source: ElementId target: ElementId - sourceHandle?: ElementId | null - targetHandle?: ElementId | null + sourceHandle?: ElementId + targetHandle?: ElementId selected?: boolean sourcePosition?: Position targetPosition?: Position @@ -153,12 +154,12 @@ const sourceHandle = controlledComputed( () => props.sourceTargetNodes, () => { if (props.sourceTargetNodes.sourceNode && props.sourceTargetNodes.sourceNode.__vf.handleBounds.source) - return getHandle(props.sourceTargetNodes.sourceNode.__vf.handleBounds.source, props.sourceHandle ?? null) + return getHandle(props.sourceTargetNodes.sourceNode.__vf.handleBounds.source, props.sourceHandle) else return null }, ) const targetHandle = computed(() => { - if (targetNodeHandles.value) return getHandle(targetNodeHandles.value, props.targetHandle ?? null) + if (targetNodeHandles.value) return getHandle(targetNodeHandles.value, props.targetHandle) else return null }) const sourcePosition = eagerComputed(() => (sourceHandle.value ? sourceHandle.value.position : Position.Bottom)) @@ -178,6 +179,17 @@ const edgePos = computed(() => targetPosition.value, ), ) + +const isVisible = ({ sourceX, sourceY, targetX, targetY }: EdgePositions) => + store.onlyRenderVisibleElements + ? isEdgeVisible({ + sourcePos: { x: sourceX, y: sourceY }, + targetPos: { x: targetX, y: targetY }, + width: store.dimensions.width, + height: store.dimensions.height, + transform: store.transform, + }) + : true