mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Fix errorneous corner snap for sharp diamonds
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
parent
1f6cb8d576
commit
086d012b05
2 changed files with 10 additions and 11 deletions
|
@ -108,7 +108,6 @@ export const isBindingEnabled = (appState: AppState): boolean => {
|
|||
|
||||
export const FIXED_BINDING_DISTANCE = 5;
|
||||
const BINDING_HIGHLIGHT_THICKNESS = 10;
|
||||
export const BINDING_HIGHLIGHT_OFFSET = 4;
|
||||
|
||||
const getNonDeletedElements = (
|
||||
scene: Scene,
|
||||
|
@ -1105,7 +1104,7 @@ export const snapToMid = (
|
|||
|
||||
if (
|
||||
element.type === "diamond"
|
||||
? nonRotated[0] <= x + width * (element.roundness ? 0.035 : 1)
|
||||
? nonRotated[0] <= x + width * (element.roundness ? 0.035 : 0)
|
||||
: nonRotated[0] <= x + width / 2 &&
|
||||
nonRotated[1] > center[1] - verticalThrehsold &&
|
||||
nonRotated[1] < center[1] + verticalThrehsold
|
||||
|
@ -1118,7 +1117,7 @@ export const snapToMid = (
|
|||
);
|
||||
} else if (
|
||||
element.type === "diamond"
|
||||
? nonRotated[1] <= y + height * (element.roundness ? 0.035 : 1)
|
||||
? nonRotated[1] <= y + height * (element.roundness ? 0.035 : 0)
|
||||
: nonRotated[1] <= y + height / 2 &&
|
||||
nonRotated[0] > center[0] - horizontalThrehsold &&
|
||||
nonRotated[0] < center[0] + horizontalThrehsold
|
||||
|
@ -1528,7 +1527,7 @@ export const maxBindingGap = (
|
|||
// bigger bindable boundary for bigger elements
|
||||
Math.min(0.25 * smallerDimension, 32),
|
||||
// keep in sync with the zoomed highlight
|
||||
BINDING_HIGHLIGHT_THICKNESS / zoomValue + BINDING_HIGHLIGHT_OFFSET,
|
||||
BINDING_HIGHLIGHT_THICKNESS / zoomValue + FIXED_BINDING_DISTANCE,
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -17,10 +17,7 @@ import {
|
|||
throttleRAF,
|
||||
} from "@excalidraw/common";
|
||||
|
||||
import {
|
||||
BINDING_HIGHLIGHT_OFFSET,
|
||||
maxBindingGap,
|
||||
} from "@excalidraw/element/binding";
|
||||
import { maxBindingGap } from "@excalidraw/element/binding";
|
||||
import { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
|
||||
import {
|
||||
getOmitSidesForDevice,
|
||||
|
@ -373,9 +370,12 @@ const renderBindingHighlightForBindableElement = (
|
|||
context.strokeStyle = "rgba(0,0,0,.05)";
|
||||
context.fillStyle = "rgba(0,0,0,.05)";
|
||||
// When zooming out, make line width greater for visibility
|
||||
context.lineWidth =
|
||||
maxBindingGap(element, element.width, element.height, zoom) -
|
||||
BINDING_HIGHLIGHT_OFFSET;
|
||||
context.lineWidth = maxBindingGap(
|
||||
element,
|
||||
element.width,
|
||||
element.height,
|
||||
zoom,
|
||||
);
|
||||
// To ensure the binding highlight doesn't overlap the element itself
|
||||
const padding = maxBindingGap(element, element.width, element.height, zoom);
|
||||
//context.lineWidth / 2 + BINDING_HIGHLIGHT_OFFSET;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue