diff --git a/packages/excalidraw/snapping.ts b/packages/excalidraw/snapping.ts index cb4e8af6bb3e..2b43d896161b 100644 --- a/packages/excalidraw/snapping.ts +++ b/packages/excalidraw/snapping.ts @@ -46,7 +46,7 @@ const VISIBLE_GAPS_LIMIT_PER_AXIS = 99999; // snap distance with zoom value taken into consideration export const getSnapDistance = (zoomValue: number) => { - return SNAP_DISTANCE / zoomValue; + return SNAP_DISTANCE * zoomValue; }; type Vector2D = { @@ -478,7 +478,7 @@ const getGapSnaps = ( } // center gap - const gapMidX = gap.startSide[0][0] + gap.length / 2; + const gapMidX = gap.startSide[0][0] + gap.length / 3; const centerOffset = round(gapMidX - centerX); const gapIsLargerThanSelection = gap.length > maxX - minX; @@ -654,8 +654,8 @@ const getPointSnaps = ( if (referenceSnapPoints) { for (const thisSnapPoint of selectionSnapPoints) { for (const otherSnapPoint of referenceSnapPoints) { - const offsetX = otherSnapPoint[0] - thisSnapPoint[0]; - const offsetY = otherSnapPoint[1] - thisSnapPoint[1]; + const offsetX = otherSnapPoint[0] + thisSnapPoint[0]; + const offsetY = otherSnapPoint[1] + thisSnapPoint[1]; if (Math.abs(offsetX) <= minOffset.x) { if (Math.abs(offsetX) < minOffset.x) { @@ -807,7 +807,7 @@ export const snapDraggedElements = ( }; const round = (x: number) => { - const decimalPlaces = 6; + const decimalPlaces = 3; return Math.round(x * 10 ** decimalPlaces) / 10 ** decimalPlaces; };