diff --git a/package-lock.json b/package-lock.json index c0632a2b..8dccfd81 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "react-flow-renderer", - "version": "8.0.0-next.9", + "version": "8.0.0-next.10", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "react-flow-renderer", - "version": "8.0.0-next.9", + "version": "8.0.0-next.10", "license": "MIT", "dependencies": { "@babel/runtime": "^7.12.5", diff --git a/package.json b/package.json index 610aea30..b18d3d22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-flow-renderer", - "version": "8.0.0-next.9", + "version": "8.0.0-next.10", "main": "dist/ReactFlow.js", "module": "dist/ReactFlow.esm.js", "types": "dist/index.d.ts", diff --git a/src/components/Edges/SmoothStepEdge.tsx b/src/components/Edges/SmoothStepEdge.tsx index eaf1b0f7..3b6b5e5c 100644 --- a/src/components/Edges/SmoothStepEdge.tsx +++ b/src/components/Edges/SmoothStepEdge.tsx @@ -55,6 +55,18 @@ export function getSmoothStepPath({ let firstCornerPath = null; let secondCornerPath = null; + if (sourceX <= targetX) { + firstCornerPath = + sourceY <= targetY ? bottomLeftCorner(sourceX, cY, cornerSize) : topLeftCorner(sourceX, cY, cornerSize); + secondCornerPath = + sourceY <= targetY ? rightTopCorner(targetX, cY, cornerSize) : rightBottomCorner(targetX, cY, cornerSize); + } else { + firstCornerPath = + sourceY < targetY ? bottomRightCorner(sourceX, cY, cornerSize) : topRightCorner(sourceX, cY, cornerSize); + secondCornerPath = + sourceY < targetY ? leftTopCorner(targetX, cY, cornerSize) : leftBottomCorner(targetX, cY, cornerSize); + } + if (leftAndRight.includes(sourcePosition) && leftAndRight.includes(targetPosition)) { if (sourceX <= targetX) { firstCornerPath = @@ -88,18 +100,6 @@ export function getSmoothStepPath({ : topRightCorner(sourceX, targetY, cornerSize); } secondCornerPath = ''; - } else { - if (sourceX <= targetX) { - firstCornerPath = - sourceY <= targetY ? bottomLeftCorner(sourceX, cY, cornerSize) : topLeftCorner(sourceX, cY, cornerSize); - secondCornerPath = - sourceY <= targetY ? rightTopCorner(targetX, cY, cornerSize) : rightBottomCorner(targetX, cY, cornerSize); - } else { - firstCornerPath = - sourceY < targetY ? bottomRightCorner(sourceX, cY, cornerSize) : topRightCorner(sourceX, cY, cornerSize); - secondCornerPath = - sourceY < targetY ? leftTopCorner(targetX, cY, cornerSize) : leftBottomCorner(targetX, cY, cornerSize); - } } return `M ${sourceX},${sourceY}${firstCornerPath}${secondCornerPath}L ${targetX},${targetY}`; diff --git a/src/components/Handle/BaseHandle.tsx b/src/components/Handle/BaseHandle.tsx index e600400a..4b7921a0 100644 --- a/src/components/Handle/BaseHandle.tsx +++ b/src/components/Handle/BaseHandle.tsx @@ -71,7 +71,7 @@ export function onMouseDown( setConnectionNodeId({ connectionNodeId: nodeId, connectionHandleId: handleId, connectionHandleType: handleType }); if (onConnectStart) { - onConnectStart(event, { nodeId, handleType }); + onConnectStart(event, { nodeId, handleId, handleType }); } function resetRecentHandle(): void { diff --git a/src/types/index.ts b/src/types/index.ts index 9fb72f7b..50e1377a 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -287,6 +287,7 @@ export type ConnectionLineComponent = React.ComponentType void; export type OnConnectStartParams = { nodeId: ElementId | null; + handleId: ElementId | null; handleType: HandleType | null; }; export type OnConnectStartFunc = (event: ReactMouseEvent, params: OnConnectStartParams) => void;