fix: Connection line not working properly (regression)
This commit is contained in:
@@ -31,33 +31,31 @@ export default defineComponent({
|
|||||||
setup(props) {
|
setup(props) {
|
||||||
const store = inject<RevueFlowStore>('store')!;
|
const store = inject<RevueFlowStore>('store')!;
|
||||||
const sourceNode = ref<Node | null>(store.nodes.find((n) => n.id === store.connectionNodeId) || null);
|
const sourceNode = ref<Node | null>(store.nodes.find((n) => n.id === store.connectionNodeId) || null);
|
||||||
|
const nodesConnectable = computed(() => store.nodesConnectable);
|
||||||
|
|
||||||
const sourceHandle = computed(() =>
|
const sourceHandle = computed(() =>
|
||||||
store.connectionHandleId && store.connectionHandleType
|
store.connectionHandleId && store.connectionHandleType
|
||||||
? sourceNode.value?.__rf.handleBounds[store.connectionHandleType].find(
|
? sourceNode.value?.__rf.handleBounds[store.connectionHandleType].find(
|
||||||
(d: HandleElement) => d.id === store.connectionHandleId
|
(d: HandleElement) => d.id === store.connectionHandleId
|
||||||
)
|
)
|
||||||
: store.connectionHandleType && sourceNode.value?.__rf.handleBounds[store.connectionHandleType][0]
|
: store.connectionHandleType && sourceNode.value?.__rf.handleBounds[store.connectionHandleType][0]
|
||||||
);
|
);
|
||||||
|
const sourceHandleX = computed(() =>
|
||||||
const sourceX = computed(() =>
|
sourceHandle.value ? sourceHandle.value.x + sourceHandle.value.width / 2 : (sourceNode.value?.__rf.width as number) / 2
|
||||||
sourceNode.value?.__rf.position.x + sourceHandle.value
|
|
||||||
? sourceHandle.value.x + sourceHandle.value.width / 2
|
|
||||||
: (sourceNode.value?.__rf.width as number) / 2
|
|
||||||
);
|
);
|
||||||
const sourceY = computed(() =>
|
const sourceHandleY = computed(() =>
|
||||||
sourceNode.value?.__rf.position.y + sourceHandle.value
|
sourceHandle.value ? sourceHandle.value.y + sourceHandle.value.height / 2 : sourceNode.value?.__rf.height
|
||||||
? sourceHandle.value.y + sourceHandle.value.height / 2
|
|
||||||
: sourceNode.value?.__rf.height
|
|
||||||
);
|
);
|
||||||
|
const sourceX = computed(() => sourceNode.value?.__rf.position.x + sourceHandleX.value);
|
||||||
|
const sourceY = computed(() => sourceNode.value?.__rf.position.y + sourceHandleY.value);
|
||||||
|
|
||||||
const targetX = computed(() => (store.connectionPosition.x - store.transform[0]) / store.transform[2]);
|
const targetX = computed(() => (store.connectionPosition.x - store.transform[0]) / store.transform[2]);
|
||||||
const targetY = computed(() => (store.connectionPosition.y - store.transform[1]) / store.transform[2]);
|
const targetY = computed(() => (store.connectionPosition.y - store.transform[1]) / store.transform[2]);
|
||||||
const targetPosition = computed(() =>
|
|
||||||
sourceHandle.value?.position === Position.Left || sourceHandle.value?.position === Position.Right
|
const isRightOrLeft = computed(
|
||||||
? Position.Left
|
() => sourceHandle.value?.position === Position.Left || sourceHandle.value?.position === Position.Right
|
||||||
: Position.Top
|
|
||||||
);
|
);
|
||||||
|
const targetPosition = computed(() => (isRightOrLeft.value ? Position.Left : Position.Top));
|
||||||
|
|
||||||
let dAttr = computed(() => `M${sourceX.value},${sourceY.value} ${targetX.value},${targetY.value}`);
|
let dAttr = computed(() => `M${sourceX.value},${sourceY.value} ${targetX.value},${targetY.value}`);
|
||||||
|
|
||||||
@@ -116,7 +114,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return () =>
|
return () =>
|
||||||
store.nodesConnectable && sourceNode.value ? (
|
nodesConnectable.value && sourceNode.value ? (
|
||||||
<g class="revue-flow__connection">
|
<g class="revue-flow__connection">
|
||||||
<path d={dAttr.value} class="revue-flow__connection-path" style={props.connectionLineStyle} />
|
<path d={dAttr.value} class="revue-flow__connection-path" style={props.connectionLineStyle} />
|
||||||
</g>
|
</g>
|
||||||
|
|||||||
Reference in New Issue
Block a user