mirror of
https://github.com/drawdb-io/drawdb.git
synced 2025-07-18 10:11:24 +00:00
Allow panning diagram over locked elements (#489)
This commit is contained in:
@@ -196,44 +196,57 @@ export default function Canvas() {
|
|||||||
|
|
||||||
if (!e.isPrimary) return;
|
if (!e.isPrimary) return;
|
||||||
|
|
||||||
|
let locked = false;
|
||||||
|
let prevCoords = { prevX: 0, prevY: 0 };
|
||||||
|
|
||||||
if (type === ObjectType.TABLE) {
|
if (type === ObjectType.TABLE) {
|
||||||
const table = tables.find((t) => t.id === id);
|
const table = tables.find((t) => t.id === id);
|
||||||
|
locked = table.locked;
|
||||||
|
|
||||||
setGrabOffset({
|
setGrabOffset({
|
||||||
x: table.x - pointer.spaces.diagram.x,
|
x: table.x - pointer.spaces.diagram.x,
|
||||||
y: table.y - pointer.spaces.diagram.y,
|
y: table.y - pointer.spaces.diagram.y,
|
||||||
});
|
});
|
||||||
setDragging((prev) => ({
|
prevCoords = { prevX: table.x, prevY: table.y };
|
||||||
...prev,
|
|
||||||
id,
|
|
||||||
element: type,
|
|
||||||
prevX: table.x,
|
|
||||||
prevY: table.y,
|
|
||||||
}));
|
|
||||||
} else if (type === ObjectType.AREA) {
|
} else if (type === ObjectType.AREA) {
|
||||||
const area = areas.find((t) => t.id === id);
|
const area = areas.find((t) => t.id === id);
|
||||||
|
locked = area.locked;
|
||||||
|
|
||||||
setGrabOffset({
|
setGrabOffset({
|
||||||
x: area.x - pointer.spaces.diagram.x,
|
x: area.x - pointer.spaces.diagram.x,
|
||||||
y: area.y - pointer.spaces.diagram.y,
|
y: area.y - pointer.spaces.diagram.y,
|
||||||
});
|
});
|
||||||
setDragging((prev) => ({
|
prevCoords = { prevX: area.x, prevY: area.y };
|
||||||
...prev,
|
|
||||||
id,
|
|
||||||
element: type,
|
|
||||||
prevX: area.x,
|
|
||||||
prevY: area.y,
|
|
||||||
}));
|
|
||||||
} else if (type === ObjectType.NOTE) {
|
} else if (type === ObjectType.NOTE) {
|
||||||
const note = notes.find((t) => t.id === id);
|
const note = notes.find((t) => t.id === id);
|
||||||
|
locked = note.locked;
|
||||||
|
|
||||||
setGrabOffset({
|
setGrabOffset({
|
||||||
x: note.x - pointer.spaces.diagram.x,
|
x: note.x - pointer.spaces.diagram.x,
|
||||||
y: note.y - pointer.spaces.diagram.y,
|
y: note.y - pointer.spaces.diagram.y,
|
||||||
});
|
});
|
||||||
|
prevCoords = { prevX: note.x, prevY: note.y };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (locked) {
|
||||||
|
setPanning({
|
||||||
|
isPanning: true,
|
||||||
|
panStart: transform.pan,
|
||||||
|
cursorStart: pointer.spaces.screen,
|
||||||
|
});
|
||||||
|
pointer.setStyle("grabbing");
|
||||||
|
} else {
|
||||||
setDragging((prev) => ({
|
setDragging((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
id,
|
id,
|
||||||
element: type,
|
element: type,
|
||||||
prevX: note.x,
|
...prevCoords,
|
||||||
prevY: note.y,
|
}));
|
||||||
|
setSelectedElement((prev) => ({
|
||||||
|
...prev,
|
||||||
|
element: type,
|
||||||
|
id: id,
|
||||||
|
open: false,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,12 +262,6 @@ export default function Canvas() {
|
|||||||
})),
|
})),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
setSelectedElement((prev) => ({
|
|
||||||
...prev,
|
|
||||||
element: type,
|
|
||||||
id: id,
|
|
||||||
open: false,
|
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -403,8 +410,6 @@ export default function Canvas() {
|
|||||||
* @param {PointerEvent} e
|
* @param {PointerEvent} e
|
||||||
*/
|
*/
|
||||||
const handlePointerDown = (e) => {
|
const handlePointerDown = (e) => {
|
||||||
if (selectedElement.open && !layout.sidebar) return;
|
|
||||||
|
|
||||||
if (!e.isPrimary) return;
|
if (!e.isPrimary) return;
|
||||||
|
|
||||||
// don't pan if the sidesheet for editing a table is open
|
// don't pan if the sidesheet for editing a table is open
|
||||||
|
Reference in New Issue
Block a user