From 85673aa80ae160dc2fda2810ce9c63df953ab9fb Mon Sep 17 00:00:00 2001 From: cqh963852 Date: Thu, 8 Oct 2026 13:27:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=9B=B4=E7=BA=BF=20hover=20=E8=B7=9F?= =?UTF-8?q?=E9=9A=8F=E7=9A=84=E8=B4=B4=E5=8D=A1=E6=89=AD=E6=9B=B2=E2=80=94?= =?UTF-8?q?=E2=80=94stepPath=20=E5=8D=8A=E5=BE=84=E8=87=AA=E9=80=82?= =?UTF-8?q?=E5=BA=94=EF=BC=88min(r,|dy|/2,dx/3)=EF=BC=89=EF=BC=8C=E5=BE=AE?= =?UTF-8?q?=E6=B5=AE=203px=20=E6=94=B6=E4=B8=BA=20r1.5=20=E6=B5=85?= =?UTF-8?q?=E5=BC=AF=EF=BC=8C=E4=B8=A4=E6=AE=B5=E5=BC=A7=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E4=BA=A4=E5=8F=A0=E5=80=92=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tutorial/src/components/RouteLine.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/tutorial/src/components/RouteLine.tsx b/apps/tutorial/src/components/RouteLine.tsx index 5e3efef..177f3a4 100644 --- a/apps/tutorial/src/components/RouteLine.tsx +++ b/apps/tutorial/src/components/RouteLine.tsx @@ -16,14 +16,18 @@ export interface LaneNode { y: number // 卡中线 y } -/** 水平出发 → R8 双弯直角步进 → 水平到达;同 y 时直线 */ +/* 水平出发 → 双弯直角步进 → 水平到达;同 y 时直线。 + * 半径自适应:垂直空间 |dy| 或水平空间不足 2r 时收缩(如 hover 微浮 dy=3), + * 否则两段弧会交叠倒置,在贴卡处扭曲成折返。 */ function stepPath(x0: number, y0: number, x1: number, y1: number, r = 8): string { - if (Math.abs(y1 - y0) < 1) return `M ${x0} ${y0} H ${x1}` + const dyAbs = Math.abs(y1 - y0) + if (dyAbs < 1) return `M ${x0} ${y0} H ${x1}` + const rr = Math.max(0.5, Math.min(r, dyAbs / 2, (x1 - x0) / 3)) const down = y1 > y0 const sweep1 = down ? 1 : 0 const sweep2 = down ? 0 : 1 - const cornerX = Math.max(x0 + r, x1 - 2 * r) - return `M ${x0} ${y0} H ${cornerX} A ${r} ${r} 0 0 ${sweep1} ${cornerX + r} ${y0 + (down ? r : -r)} V ${y1 - (down ? r : -r)} A ${r} ${r} 0 0 ${sweep2} ${cornerX + 2 * r} ${y1} H ${x1}` + const cornerX = Math.max(x0 + rr, x1 - 2 * rr) + return `M ${x0} ${y0} H ${cornerX} A ${rr} ${rr} 0 0 ${sweep1} ${cornerX + rr} ${y0 + (down ? rr : -rr)} V ${y1 - (down ? rr : -rr)} A ${rr} ${rr} 0 0 ${sweep2} ${cornerX + 2 * rr} ${y1} H ${x1}` } const HOVER_LIFT = -3 // 与 MemphisCard hover:-translate-y-[3px] 一致