fix(core): correct connection line calculation

This commit is contained in:
braks
2023-06-15 22:35:25 +02:00
committed by Braks
parent c4c9283f3a
commit 33b6fe121a
3 changed files with 156 additions and 196 deletions
@@ -2,7 +2,7 @@
import { getCurrentInstance, inject, resolveComponent } from 'vue'
import { controlledComputed } from '@vueuse/core'
import EdgeWrapper from '../../components/Edges/EdgeWrapper'
import ConnectionLine from '../../components/ConnectionLine/ConnectionLine.vue'
import ConnectionLine from '../../components/ConnectionLine'
import type { EdgeComponent, EdgeUpdatable, GraphEdge } from '../../types'
import { Slots } from '../../context'
import { useVueFlow } from '../../composables'
@@ -12,8 +12,6 @@ import MarkerDefinitions from './MarkerDefinitions.vue'
const slots = inject(Slots)
const {
connectionStartHandle,
nodesConnectable,
edgesUpdatable,
edgesFocusable,
elementsSelectable,
@@ -28,28 +26,6 @@ const {
emits,
} = useVueFlow()
const sourceNode = controlledComputed(
() => connectionStartHandle.value?.nodeId,
() => {
if (connectionStartHandle.value?.nodeId) {
return findNode(connectionStartHandle.value.nodeId)
}
return false
},
)
const connectionLineVisible = controlledComputed(
() => connectionStartHandle.value?.nodeId,
() =>
!!(
sourceNode.value &&
(typeof sourceNode.value.connectable === 'undefined' ? nodesConnectable.value : sourceNode.value.connectable) &&
connectionStartHandle.value?.nodeId &&
connectionStartHandle.value?.type
),
)
const groups = controlledComputed(
[
() => edges.value.map((e) => e.zIndex),
@@ -127,8 +103,6 @@ export default {
</g>
</svg>
<svg v-if="connectionLineVisible && !!sourceNode" class="vue-flow__edges vue-flow__connectionline vue-flow__container">
<ConnectionLine :source-node="sourceNode" />
</svg>
<ConnectionLine />
</template>
</template>