From c1a29beb1dd91a0ca326a1d5dfc63c6aae69066a Mon Sep 17 00:00:00 2001 From: Ze-Zheng Wu Date: Fri, 18 Mar 2022 18:59:20 +0800 Subject: [PATCH] assume toPosition is opposite to fromPosition --- src/components/ConnectionLine/index.tsx | 10 ++-------- src/components/Edges/BezierEdge.tsx | 8 ++------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/components/ConnectionLine/index.tsx b/src/components/ConnectionLine/index.tsx index be358821..dfdf248f 100644 --- a/src/components/ConnectionLine/index.tsx +++ b/src/components/ConnectionLine/index.tsx @@ -82,8 +82,6 @@ export default ({ targetY: number, targetPosition: Position | undefined; - let toCurvature: 'sourceCurvature' | 'targetCurvature'; - switch (connectionHandleType) { case 'source': { @@ -93,7 +91,6 @@ export default ({ targetX = toX; targetY = toY; targetPosition = toPosition; - toCurvature = 'targetCurvature'; } break; case 'target': @@ -104,7 +101,6 @@ export default ({ targetX = fromX; targetY = fromY; targetPosition = fromPosition; - toCurvature = 'sourceCurvature'; } break; } @@ -143,10 +139,8 @@ export default ({ }; if (connectionLineType === ConnectionLineType.Bezier) { - // we don't know the destination position, so we can zero the to curvature - dAttr = getBezierPath({ ...pathParams, [toCurvature]: 0 }); - // or we assume the destination position is opposite to the source position - // dAttr = getBezierPath(pathParams); + // we assume the destination position is opposite to the source position + dAttr = getBezierPath(pathParams); } else if (connectionLineType === ConnectionLineType.Step) { dAttr = getSmoothStepPath({ ...pathParams, diff --git a/src/components/Edges/BezierEdge.tsx b/src/components/Edges/BezierEdge.tsx index df9ab8fd..aac7e2de 100644 --- a/src/components/Edges/BezierEdge.tsx +++ b/src/components/Edges/BezierEdge.tsx @@ -11,8 +11,6 @@ export interface GetBezierPathParams { targetY: number; targetPosition?: Position; curvature?: number; - sourceCurvature?: number; - targetCurvature?: number; centerX?: number; centerY?: number; } @@ -91,8 +89,6 @@ export function getBezierPath({ targetY, targetPosition = Position.Top, curvature = 0.25, - sourceCurvature = curvature, - targetCurvature = curvature, centerX, centerY, }: GetBezierPathParams): string { @@ -107,7 +103,7 @@ export function getBezierPath({ y2: targetY, cX: centerX, cY: centerY, - c: sourceCurvature, + c: curvature, }); const [targetControlX, targetControlY] = getControlWithCurvature({ pos: targetPosition, @@ -117,7 +113,7 @@ export function getBezierPath({ y2: sourceY, cX: centerX, cY: centerY, - c: targetCurvature, + c: curvature, }); return `M${sourceX},${sourceY} C${sourceControlX},${sourceControlY} ${targetControlX},${targetControlY} ${targetX},${targetY}`; }