diff --git a/packages/element/src/binding.ts b/packages/element/src/binding.ts index 10fa9b1bb..0f9188c04 100644 --- a/packages/element/src/binding.ts +++ b/packages/element/src/binding.ts @@ -959,10 +959,7 @@ export const bindPointToSnapToElementOutline = ( otherPoint, ), ), - FIXED_BINDING_DISTANCE * - (bindableElement.type === "diamond" - ? 1.414 // sqrt(2) - : 1), + FIXED_BINDING_DISTANCE, )[0]; } else { intersection = intersectElementWithLineSegment( @@ -1180,7 +1177,7 @@ export const snapToMid = ( )[0] ?? otherPoint ); } else if (element.type === "diamond") { - const distance = FIXED_BINDING_DISTANCE * 0.7071; // 1 / sqrt(2) + const distance = FIXED_BINDING_DISTANCE; const topLeft = pointFrom( x + width / 4 - distance, y + height / 4 - distance, @@ -1202,25 +1199,25 @@ export const snapToMid = ( pointDistance(topLeft, nonRotated) < Math.max(horizontalThreshold, verticalThreshold) ) { - return topLeft; + return pointRotateRads(topLeft, center, angle); } if ( pointDistance(topRight, nonRotated) < Math.max(horizontalThreshold, verticalThreshold) ) { - return topRight; + return pointRotateRads(topRight, center, angle); } if ( pointDistance(bottomLeft, nonRotated) < Math.max(horizontalThreshold, verticalThreshold) ) { - return bottomLeft; + return pointRotateRads(bottomLeft, center, angle); } if ( pointDistance(bottomRight, nonRotated) < Math.max(horizontalThreshold, verticalThreshold) ) { - return bottomRight; + return pointRotateRads(bottomRight, center, angle); } } diff --git a/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap index 6d9d7f090..5e3f00c31 100644 --- a/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap +++ b/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap @@ -779,7 +779,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "fillStyle": "solid", "frameId": null, "groupIds": [], - "height": "0.00000", + "height": 0, "id": "id668", "index": "a2", "isDeleted": false, @@ -855,14 +855,14 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl ], [ 100, - "-0.00000", + 0, ], ], }, "inserted": { "endBinding": { "elementId": "id665", - "focus": "0.00000", + "focus": -0, "gap": 1, }, "points": [ @@ -918,7 +918,6 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl ], ], "startBinding": null, - "y": 0, }, "inserted": { "points": [ @@ -928,15 +927,14 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl ], [ 100, - "-0.00000", + 0, ], ], "startBinding": { "elementId": "id664", - "focus": "-0.00000", + "focus": 0, "gap": 1, }, - "y": "0.00000", }, }, },