From 04d915f65fa51f9ade5b47d11b772b75128947fd Mon Sep 17 00:00:00 2001 From: sunhao Date: Mon, 27 May 2024 13:47:26 +0800 Subject: [PATCH] * kanban: optimize link path with curve shape. --- lib/kanban/src/helpers/link-helpers.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/kanban/src/helpers/link-helpers.ts b/lib/kanban/src/helpers/link-helpers.ts index c7ee5e43b0..4515b3b639 100644 --- a/lib/kanban/src/helpers/link-helpers.ts +++ b/lib/kanban/src/helpers/link-helpers.ts @@ -131,16 +131,16 @@ export function getPointMarker(type: KanbanLinkPointType, side: 'start' | 'end', return marker; } -export function getLinkPath(fromPos: ElementPos, toPos: ElementPos, fromSide: KanbanLinkSide, toSide: KanbanLinkSide, shape: KanbanLinkShape = 'curve', strokeWidth: number = 2): string { +export function getLinkPath(fromPos: ElementPos, toPos: ElementPos, fromSide: KanbanLinkSide, toSide: KanbanLinkSide, shape: KanbanLinkShape = 'curve', strokeWidth: number = 2, curveRate = 1): string { const { x, y, width, height, } = getRectOfTwoPos(fromPos, toPos); const deltaX = SVG_PADDING - x; const deltaY = SVG_PADDING - y; if (shape === 'curve') { - const ctrlWidth = width * 0.7; - const ctrlHeight = height * 0.7; - const startLength = strokeWidth * 2; // default is 8; + const ctrlWidth = width * (1 + Math.max(-0.3, Math.min(0.3, (1 - (width / 50))))) * curveRate; + const ctrlHeight = height * (1 + Math.max(-0.3, Math.min(0.3, (1 - (height / 50))))) * curveRate; + const startLength = strokeWidth * 5; // default is 8; const ctrlPos = { a1x: fromPos.x + (fromSide === 'left' ? -startLength : (fromSide === 'right' ? startLength : 0)), a1y: fromPos.y + (fromSide === 'top' ? -startLength : (fromSide === 'bottom' ? startLength : 0)),