fix: elbow arrow endpoint drag with Ctrl held does not snap but tries to select (#12)

* change snapping logic

* remove selection box

* snapping

* formatted with prettier

---------

Co-authored-by: Michaelli8899 <147345359+Michaelli8899@users.noreply.github.com>
pull/8884/head
dominicteh1 2 months ago committed by GitHub
parent f96692c783
commit 8ba96aed9a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -298,20 +298,44 @@ export class LinearElementEditor {
const snapAngle = Math.round(angle / 15) * 15;
// Only remove midpoints for cardinal angles
if ([0, 90, 180, 270, 360].includes(snapAngle)) {
const newPoints = [
element.points[0],
element.points[element.points.length - 1],
];
const { x: rx, y: ry } = element;
const [gridX, gridY] = getGridPoint(
scenePointerX,
scenePointerY,
null,
);
const [lastCommittedX, lastCommittedY] =
element.lastCommittedPoint ?? [0, 0];
let dxFromLastCommitted = gridX - rx - lastCommittedX;
let dyFromLastCommitted = gridY - ry - lastCommittedY;
({ width: dxFromLastCommitted, height: dyFromLastCommitted } =
getLockedLinearCursorAlignSize(
// actual coordinate of the last committed point
lastCommittedX + rx,
lastCommittedY + ry,
// cursor-grid coordinate
gridX,
gridY,
));
mutateElbowArrow(
element,
elementsMap,
newPoints,
vector(0, 0),
[
...element.points.slice(0, -1),
pointFrom<LocalPoint>(
lastCommittedX + dxFromLastCommitted,
lastCommittedY + dyFromLastCommitted,
),
],
undefined,
undefined,
{
startBinding: element.startBinding,
endBinding: element.endBinding,
isDragging: true,
informMutation: false,
},
{ isDragging: true },
);
if (selectedIndex > 0) {
selectedIndex = 1;
@ -321,7 +345,7 @@ export class LinearElementEditor {
const referencePoint =
element.points[selectedIndex === 0 ? 1 : selectedIndex - 1];
const [width, height] = LinearElementEditor._getShiftLockedDelta(
element,
elementsMap,

Loading…
Cancel
Save