Skip to content

Commit

Permalink
assume toPosition is opposite to fromPosition
Browse files Browse the repository at this point in the history
  • Loading branch information
Sec-ant committed Mar 18, 2022
1 parent 0ff6380 commit c1a29be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
10 changes: 2 additions & 8 deletions src/components/ConnectionLine/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ export default ({
targetY: number,
targetPosition: Position | undefined;

let toCurvature: 'sourceCurvature' | 'targetCurvature';

switch (connectionHandleType) {
case 'source':
{
Expand All @@ -93,7 +91,6 @@ export default ({
targetX = toX;
targetY = toY;
targetPosition = toPosition;
toCurvature = 'targetCurvature';
}
break;
case 'target':
Expand All @@ -104,7 +101,6 @@ export default ({
targetX = fromX;
targetY = fromY;
targetPosition = fromPosition;
toCurvature = 'sourceCurvature';
}
break;
}
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 2 additions & 6 deletions src/components/Edges/BezierEdge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export interface GetBezierPathParams {
targetY: number;
targetPosition?: Position;
curvature?: number;
sourceCurvature?: number;
targetCurvature?: number;
centerX?: number;
centerY?: number;
}
Expand Down Expand Up @@ -91,8 +89,6 @@ export function getBezierPath({
targetY,
targetPosition = Position.Top,
curvature = 0.25,
sourceCurvature = curvature,
targetCurvature = curvature,
centerX,
centerY,
}: GetBezierPathParams): string {
Expand All @@ -107,7 +103,7 @@ export function getBezierPath({
y2: targetY,
cX: centerX,
cY: centerY,
c: sourceCurvature,
c: curvature,
});
const [targetControlX, targetControlY] = getControlWithCurvature({
pos: targetPosition,
Expand All @@ -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}`;
}
Expand Down

0 comments on commit c1a29be

Please sign in to comment.