Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/excalidraw/snapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
};

Expand Down