From 392118bf260529aba49371db78be4439ac2ede9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rk=20Tolm=C3=A1cs?= Date: Fri, 28 Feb 2025 15:36:41 +0100 Subject: [PATCH] fix: Fix elbow arrow fixed binding on restore (#9197) --- packages/excalidraw/element/binding.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/excalidraw/element/binding.ts b/packages/excalidraw/element/binding.ts index 332a70fcdc..2ac8b7c698 100644 --- a/packages/excalidraw/element/binding.ts +++ b/packages/excalidraw/element/binding.ts @@ -2206,9 +2206,13 @@ export const normalizeFixedPoint = ( ): T extends null ? null : FixedPoint => { // Do not allow a precise 0.5 for fixed point ratio // to avoid jumping arrow heading due to floating point imprecision - if (fixedPoint && (fixedPoint[0] === 0.5 || fixedPoint[1] === 0.5)) { + if ( + fixedPoint && + (Math.abs(fixedPoint[0] - 0.5) < 0.0001 || + Math.abs(fixedPoint[1] - 0.5) < 0.0001) + ) { return fixedPoint.map((ratio) => - ratio === 0.5 ? 0.5001 : ratio, + Math.abs(ratio - 0.5) < 0.0001 ? 0.5001 : ratio, ) as T extends null ? null : FixedPoint; } return fixedPoint as any as T extends null ? null : FixedPoint;