assume toPosition is opposite to fromPosition
This commit is contained in:
@@ -82,8 +82,6 @@ export default ({
|
|||||||
targetY: number,
|
targetY: number,
|
||||||
targetPosition: Position | undefined;
|
targetPosition: Position | undefined;
|
||||||
|
|
||||||
let toCurvature: 'sourceCurvature' | 'targetCurvature';
|
|
||||||
|
|
||||||
switch (connectionHandleType) {
|
switch (connectionHandleType) {
|
||||||
case 'source':
|
case 'source':
|
||||||
{
|
{
|
||||||
@@ -93,7 +91,6 @@ export default ({
|
|||||||
targetX = toX;
|
targetX = toX;
|
||||||
targetY = toY;
|
targetY = toY;
|
||||||
targetPosition = toPosition;
|
targetPosition = toPosition;
|
||||||
toCurvature = 'targetCurvature';
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'target':
|
case 'target':
|
||||||
@@ -104,7 +101,6 @@ export default ({
|
|||||||
targetX = fromX;
|
targetX = fromX;
|
||||||
targetY = fromY;
|
targetY = fromY;
|
||||||
targetPosition = fromPosition;
|
targetPosition = fromPosition;
|
||||||
toCurvature = 'sourceCurvature';
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -143,10 +139,8 @@ export default ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (connectionLineType === ConnectionLineType.Bezier) {
|
if (connectionLineType === ConnectionLineType.Bezier) {
|
||||||
// we don't know the destination position, so we can zero the to curvature
|
// we assume the destination position is opposite to the source position
|
||||||
dAttr = getBezierPath({ ...pathParams, [toCurvature]: 0 });
|
dAttr = getBezierPath(pathParams);
|
||||||
// or we assume the destination position is opposite to the source position
|
|
||||||
// dAttr = getBezierPath(pathParams);
|
|
||||||
} else if (connectionLineType === ConnectionLineType.Step) {
|
} else if (connectionLineType === ConnectionLineType.Step) {
|
||||||
dAttr = getSmoothStepPath({
|
dAttr = getSmoothStepPath({
|
||||||
...pathParams,
|
...pathParams,
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ export interface GetBezierPathParams {
|
|||||||
targetY: number;
|
targetY: number;
|
||||||
targetPosition?: Position;
|
targetPosition?: Position;
|
||||||
curvature?: number;
|
curvature?: number;
|
||||||
sourceCurvature?: number;
|
|
||||||
targetCurvature?: number;
|
|
||||||
centerX?: number;
|
centerX?: number;
|
||||||
centerY?: number;
|
centerY?: number;
|
||||||
}
|
}
|
||||||
@@ -91,8 +89,6 @@ export function getBezierPath({
|
|||||||
targetY,
|
targetY,
|
||||||
targetPosition = Position.Top,
|
targetPosition = Position.Top,
|
||||||
curvature = 0.25,
|
curvature = 0.25,
|
||||||
sourceCurvature = curvature,
|
|
||||||
targetCurvature = curvature,
|
|
||||||
centerX,
|
centerX,
|
||||||
centerY,
|
centerY,
|
||||||
}: GetBezierPathParams): string {
|
}: GetBezierPathParams): string {
|
||||||
@@ -107,7 +103,7 @@ export function getBezierPath({
|
|||||||
y2: targetY,
|
y2: targetY,
|
||||||
cX: centerX,
|
cX: centerX,
|
||||||
cY: centerY,
|
cY: centerY,
|
||||||
c: sourceCurvature,
|
c: curvature,
|
||||||
});
|
});
|
||||||
const [targetControlX, targetControlY] = getControlWithCurvature({
|
const [targetControlX, targetControlY] = getControlWithCurvature({
|
||||||
pos: targetPosition,
|
pos: targetPosition,
|
||||||
@@ -117,7 +113,7 @@ export function getBezierPath({
|
|||||||
y2: sourceY,
|
y2: sourceY,
|
||||||
cX: centerX,
|
cX: centerX,
|
||||||
cY: centerY,
|
cY: centerY,
|
||||||
c: targetCurvature,
|
c: curvature,
|
||||||
});
|
});
|
||||||
return `M${sourceX},${sourceY} C${sourceControlX},${sourceControlY} ${targetControlX},${targetControlY} ${targetX},${targetY}`;
|
return `M${sourceX},${sourceY} C${sourceControlX},${sourceControlY} ${targetControlX},${targetControlY} ${targetX},${targetY}`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user