mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: Round coordinates and sizes for rectangle intersection (#8366)
Round coordinates and sizes for rectangle intersection
This commit is contained in:
parent
97981804d7
commit
5daf1a1b4e
1 changed files with 24 additions and 2 deletions
|
@ -765,7 +765,18 @@ export const bindPointToSnapToElementOutline = (
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
const d = distanceToBindableElement(bindableElement, i, elementsMap);
|
const d = distanceToBindableElement(
|
||||||
|
{
|
||||||
|
...bindableElement,
|
||||||
|
x: Math.round(bindableElement.x),
|
||||||
|
y: Math.round(bindableElement.y),
|
||||||
|
width: Math.round(bindableElement.width),
|
||||||
|
height: Math.round(bindableElement.height),
|
||||||
|
},
|
||||||
|
[Math.round(i[0]), Math.round(i[1])],
|
||||||
|
new Map(),
|
||||||
|
);
|
||||||
|
|
||||||
return d >= bindableElement.height / 2 || d < FIXED_BINDING_DISTANCE
|
return d >= bindableElement.height / 2 || d < FIXED_BINDING_DISTANCE
|
||||||
? ([point[0], -1 * i[1]] as Point)
|
? ([point[0], -1 * i[1]] as Point)
|
||||||
: ([point[0], i[1]] as Point);
|
: ([point[0], i[1]] as Point);
|
||||||
|
@ -781,7 +792,18 @@ export const bindPointToSnapToElementOutline = (
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
const d = distanceToBindableElement(bindableElement, i, elementsMap);
|
const d = distanceToBindableElement(
|
||||||
|
{
|
||||||
|
...bindableElement,
|
||||||
|
x: Math.round(bindableElement.x),
|
||||||
|
y: Math.round(bindableElement.y),
|
||||||
|
width: Math.round(bindableElement.width),
|
||||||
|
height: Math.round(bindableElement.height),
|
||||||
|
},
|
||||||
|
[Math.round(i[0]), Math.round(i[1])],
|
||||||
|
new Map(),
|
||||||
|
);
|
||||||
|
|
||||||
return d >= bindableElement.width / 2 || d < FIXED_BINDING_DISTANCE
|
return d >= bindableElement.width / 2 || d < FIXED_BINDING_DISTANCE
|
||||||
? ([-1 * i[0], point[1]] as Point)
|
? ([-1 * i[0], point[1]] as Point)
|
||||||
: ([i[0], point[1]] as Point);
|
: ([i[0], point[1]] as Point);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue