fix(connectionLine): sourceHandle with connectionMode = loose

This commit is contained in:
Clément Loridan
2021-09-22 18:07:24 +02:00
parent b3f102ce1b
commit ae4bce1295
3 changed files with 27 additions and 5 deletions
+17 -3
View File
@@ -53,9 +53,22 @@ export default ({
return null;
}
const sourceHandle = handleId
? sourceNode.__rf.handleBounds[connectionHandleType].find((d: HandleElement) => d.id === handleId)
: sourceNode.__rf.handleBounds[connectionHandleType][0];
const getSourceHandle = (handleId: ElementId | null, sourceNode: Node) => {
const handleBound = sourceNode.__rf.handleBounds[connectionHandleType];
if (handleBound) {
if (handleId) {
return sourceNode.__rf.handleBounds[connectionHandleType].find((d: HandleElement) => d.id === handleId);
}
return sourceNode.__rf.handleBounds[connectionHandleType][0]
}
const handleType = connectionHandleType === 'source' ? 'target' : 'source';
if (handleId) {
return sourceNode.__rf.handleBounds[handleType].find((d: HandleElement) => d.id === handleId);
}
return sourceNode.__rf.handleBounds[handleType][0]
}
const sourceHandle = getSourceHandle(handleId, sourceNode);
const sourceHandleX = sourceHandle ? sourceHandle.x + sourceHandle.width / 2 : sourceNode.__rf.width / 2;
const sourceHandleY = sourceHandle ? sourceHandle.y + sourceHandle.height / 2 : sourceNode.__rf.height;
const sourceX = sourceNode.__rf.position.x + sourceHandleX;
@@ -68,6 +81,7 @@ export default ({
const targetPosition = isRightOrLeft ? Position.Left : Position.Top;
if (CustomConnectionLineComponent) {
return (
<g className="react-flow__connection">
<CustomConnectionLineComponent