chore(bezier-edge): less curvy by default
This commit is contained in:
@@ -3,7 +3,6 @@ import { EdgeProps, Position } from '../../types';
|
|||||||
import BaseEdge from './BaseEdge';
|
import BaseEdge from './BaseEdge';
|
||||||
import { getCenter } from './utils';
|
import { getCenter } from './utils';
|
||||||
|
|
||||||
|
|
||||||
export interface GetBezierPathParams {
|
export interface GetBezierPathParams {
|
||||||
sourceX: number;
|
sourceX: number;
|
||||||
sourceY: number;
|
sourceY: number;
|
||||||
@@ -23,7 +22,7 @@ export function getBezierPath({
|
|||||||
targetX,
|
targetX,
|
||||||
targetY,
|
targetY,
|
||||||
targetPosition = Position.Top,
|
targetPosition = Position.Top,
|
||||||
curvature = 0.4,
|
curvature = 0.25,
|
||||||
centerX,
|
centerX,
|
||||||
centerY,
|
centerY,
|
||||||
}: GetBezierPathParams): string {
|
}: GetBezierPathParams): string {
|
||||||
@@ -43,7 +42,7 @@ export function getBezierPath({
|
|||||||
const hx1 = hasCurvature && distanceX < 0 ? sourceX + amtX : cX;
|
const hx1 = hasCurvature && distanceX < 0 ? sourceX + amtX : cX;
|
||||||
const hx2 = hasCurvature && distanceX < 0 ? targetX - amtX : cX;
|
const hx2 = hasCurvature && distanceX < 0 ? targetX - amtX : cX;
|
||||||
|
|
||||||
return `M${sourceX},${sourceY} C${hx1},${sourceY} ${hx2},${targetY}, ${targetX},${targetY}`
|
return `M${sourceX},${sourceY} C${hx1},${sourceY} ${hx2},${targetY}, ${targetX},${targetY}`;
|
||||||
} else if (leftAndRight.includes(targetPosition)) {
|
} else if (leftAndRight.includes(targetPosition)) {
|
||||||
return `M${sourceX},${sourceY} Q${sourceX},${targetY} ${targetX},${targetY}`;
|
return `M${sourceX},${sourceY} Q${sourceX},${targetY} ${targetX},${targetY}`;
|
||||||
} else if (leftAndRight.includes(sourcePosition)) {
|
} else if (leftAndRight.includes(sourcePosition)) {
|
||||||
@@ -59,8 +58,7 @@ export function getBezierPath({
|
|||||||
const hy1 = hasCurvature && distanceY < 0 ? sourceY + amtY : cY;
|
const hy1 = hasCurvature && distanceY < 0 ? sourceY + amtY : cY;
|
||||||
const hy2 = hasCurvature && distanceY < 0 ? targetY - amtY : cY;
|
const hy2 = hasCurvature && distanceY < 0 ? targetY - amtY : cY;
|
||||||
|
|
||||||
return `M${sourceX},${sourceY} C${sourceX},${hy1} ${targetX},${hy2} ${targetX},${targetY}`
|
return `M${sourceX},${sourceY} C${sourceX},${hy1} ${targetX},${hy2} ${targetX},${targetY}`;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default memo(
|
export default memo(
|
||||||
|
|||||||
Reference in New Issue
Block a user