diff --git a/packages/element/src/utils.ts b/packages/element/src/utils.ts index 8a293180b2..04bc78d4c6 100644 --- a/packages/element/src/utils.ts +++ b/packages/element/src/utils.ts @@ -724,14 +724,11 @@ const getSnappedMidpointIndexForSimpleArrow = ( element: ExcalidrawBindableElement, point: GlobalPoint, elementsMap: ElementsMap, - horizontalThreshold: number, - verticalThreshold: number, + threshold: number, ) => { const baseMidpoints = getAllMidpoints(element, elementsMap); for (let i = 0; i < baseMidpoints.length; i++) { - const threshold = i % 2 === 0 ? horizontalThreshold : verticalThreshold; - if ( pointDistance(baseMidpoints[i], point) <= threshold && !hitElementItself({ @@ -810,8 +807,7 @@ export const getSnapOutlineMidPoint = ( element, point, elementsMap, - horizontalThreshold, - verticalThreshold, + maxDistance, ); if (idx === -1) { diff --git a/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap index e39fd4af73..f5652ca24d 100644 --- a/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap +++ b/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap @@ -2469,7 +2469,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "endBinding": { "elementId": "id1", "fixedPoint": [ - "0.50010", + 0, "0.50010", ], "mode": "orbit", @@ -2477,7 +2477,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "fillStyle": "solid", "frameId": null, "groupIds": [], - "height": "399.26547", + "height": "439.20000", "id": "id4", "index": "a2", "isDeleted": false, @@ -2491,8 +2491,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl 0, ], [ - "488.00000", - "-399.26547", + 488, + "-439.20000", ], ], "roughness": 1, @@ -2514,9 +2514,9 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "type": "arrow", "updated": 1, "version": 11, - "width": "488.00000", + "width": 488, "x": 6, - "y": "-4.89900", + "y": "-5.39000", } `; @@ -2640,7 +2640,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "endBinding": { "elementId": "id1", "fixedPoint": [ - "0.50010", + 0, "0.50010", ], "mode": "orbit", @@ -2648,7 +2648,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "fillStyle": "solid", "frameId": null, "groupIds": [], - "height": "399.26547", + "height": "439.20000", "index": "a2", "isDeleted": false, "link": null, @@ -2660,8 +2660,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl 0, ], [ - "488.00000", - "-399.26547", + 488, + "-439.20000", ], ], "roughness": 1, @@ -2682,9 +2682,9 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "strokeWidth": 2, "type": "arrow", "version": 11, - "width": "488.00000", + "width": 488, "x": 6, - "y": "-4.89900", + "y": "-5.39000", }, "inserted": { "isDeleted": true, diff --git a/packages/excalidraw/tests/__snapshots__/move.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/move.test.tsx.snap index c1fe53d95d..2e0179e098 100644 --- a/packages/excalidraw/tests/__snapshots__/move.test.tsx.snap +++ b/packages/excalidraw/tests/__snapshots__/move.test.tsx.snap @@ -168,7 +168,7 @@ exports[`move element > rectangles with binding arrow 6`] = ` "type": "rectangle", "updated": 1, "version": 7, - "versionNonce": 735304455, + "versionNonce": 888958951, "width": 300, "x": 201, "y": 2, @@ -232,8 +232,8 @@ exports[`move element > rectangles with binding arrow 7`] = ` "strokeWidth": 2, "type": "arrow", "updated": 1, - "version": 13, - "versionNonce": 271613161, + "version": 12, + "versionNonce": 2066753033, "width": 89, "x": 106, "y": "56.01120", diff --git a/packages/excalidraw/tests/history.test.tsx b/packages/excalidraw/tests/history.test.tsx index 6b026fee66..0c7514c972 100644 --- a/packages/excalidraw/tests/history.test.tsx +++ b/packages/excalidraw/tests/history.test.tsx @@ -5133,7 +5133,7 @@ describe("history", () => { }), endBinding: expect.objectContaining({ elementId: rect2.id, - fixedPoint: expect.arrayContaining([0.5001, 0.5001]), + fixedPoint: expect.arrayContaining([0, 0.5001]), }), isDeleted: true, }), diff --git a/packages/excalidraw/tests/move.test.tsx b/packages/excalidraw/tests/move.test.tsx index ad7b81bf78..0dd0b1bdc3 100644 --- a/packages/excalidraw/tests/move.test.tsx +++ b/packages/excalidraw/tests/move.test.tsx @@ -116,13 +116,10 @@ describe("move element", () => { expect([rectA.x, rectA.y]).toEqual([0, 0]); expect([rectB.x, rectB.y]).toEqual([200, 0]); expect([[arrow.x, arrow.y]]).toCloselyEqualPoints( - [[106, 56.011199999998695]], - 0, - ); - expect([[arrow.width, arrow.height]]).toCloselyEqualPoints( - [[88, 88.01760000000121]], + [[106.00000000000001, 55.6867741935484]], 0, ); + expect([[arrow.width, arrow.height]]).toCloselyEqualPoints([[88, 88]], 0); renderInteractiveScene.mockClear(); renderStaticScene.mockClear(); @@ -141,13 +138,10 @@ describe("move element", () => { expect([rectA.x, rectA.y]).toEqual([0, 0]); expect([rectB.x, rectB.y]).toEqual([201, 2]); expect([[arrow.x, arrow.y]]).toCloselyEqualPoints( - [[106, 56.011199999998695]], - 0, - ); - expect([[arrow.width, arrow.height]]).toCloselyEqualPoints( - [[89, 90.01760000000121]], + [[106, 55.6867741935484]], 0, ); + expect([[arrow.width, arrow.height]]).toCloselyEqualPoints([[89, 90]], 0); h.elements.forEach((element) => expect(element).toMatchSnapshot()); });