Fix the grid and angle lock

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mark Tolmacs 2025-04-09 12:15:04 +02:00
parent 3068787ac4
commit 3f9c6299a0
No known key found for this signature in database

View file

@ -96,13 +96,7 @@ export function onPointerMoveFromPointerDownOnLinearElement(
{ {
points: [ points: [
...points, ...points,
LinearElementEditor.createPointAt( pointFrom<LocalPoint>(x - newElement.x, y - newElement.y),
newElement,
elementsMap,
x,
y,
app.getEffectiveGridSize(),
),
], ],
}, },
false, false,
@ -111,35 +105,28 @@ export function onPointerMoveFromPointerDownOnLinearElement(
points.length === 2 || points.length === 2 ||
(points.length > 1 && isElbowArrow(newElement)) (points.length > 1 && isElbowArrow(newElement))
) { ) {
const targets = [ const targets = [];
{
if (isArrowElement(newElement)) {
const [endX, endY] = getOutlineAvoidingPoint(
newElement,
pointFrom<GlobalPoint>(pointerCoords.x, pointerCoords.y),
points.length - 1,
app.scene,
app.state.zoom,
pointFrom<GlobalPoint>(newElement.x + dx, newElement.y + dy),
);
targets.push({
index: points.length - 1,
isDragging: true,
point: pointFrom<LocalPoint>(endX - newElement.x, endY - newElement.y),
});
} else {
targets.push({
index: points.length - 1, index: points.length - 1,
isDragging: true, isDragging: true,
point: pointFrom<LocalPoint>(dx, dy), point: pointFrom<LocalPoint>(dx, dy),
},
];
if (isArrowElement(newElement)) {
const [x, y] = getOutlineAvoidingPoint(
newElement,
pointFrom<GlobalPoint>(
pointerDownState.origin.x,
pointerDownState.origin.y,
),
0,
app.scene,
app.state.zoom,
);
targets.unshift({
index: 0,
isDragging: false,
point: LinearElementEditor.createPointAt(
newElement,
elementsMap,
x,
y,
app.getEffectiveGridSize(),
),
}); });
} }
@ -223,11 +210,9 @@ export function handleCanvasPointerMoveForLinearElement(
const [gridX, gridY] = getGridPoint( const [gridX, gridY] = getGridPoint(
scenePointerX, scenePointerX,
scenePointerY, scenePointerY,
event[KEYS.CTRL_OR_CMD] || isElbowArrow(multiElement) event[KEYS.CTRL_OR_CMD] ? null : app.getEffectiveGridSize(),
? null
: app.getEffectiveGridSize(),
); );
console.log(points);
const [lastCommittedX, lastCommittedY] = const [lastCommittedX, lastCommittedY] =
multiElement?.lastCommittedPoint ?? [0, 0]; multiElement?.lastCommittedPoint ?? [0, 0];
@ -268,13 +253,7 @@ export function handleCanvasPointerMoveForLinearElement(
LinearElementEditor.movePoints(multiElement, [ LinearElementEditor.movePoints(multiElement, [
{ {
index: points.length - 1, index: points.length - 1,
point: LinearElementEditor.createPointAt( point: pointFrom<LocalPoint>(x - multiElement.x, y - multiElement.y),
multiElement,
app.scene.getNonDeletedElementsMap(),
x,
y,
app.getEffectiveGridSize(),
),
isDragging: true, isDragging: true,
}, },
]); ]);