add panning for the line

This commit is contained in:
1ilit 2023-09-19 15:47:47 +03:00
parent 5e2c205f39
commit 09f7142d75

View File

@ -51,12 +51,22 @@ export default function Canvas(props) {
const dy = e.clientY - panOffset.y;
setPanOffset({ x: e.clientX, y: e.clientY });
const updatedTables = props.tables.map((t) => ({
...t,
x: t.x + dx,
y: t.y + dy,
}));
props.setTables(updatedTables);
props.setTables(
props.tables.map((t) => ({
...t,
x: t.x + dx,
y: t.y + dy,
}))
);
setRelationships(
relationships.map((r) => ({
startX: r.startX + dx,
startY: r.startY + dy,
endX: r.endX + dx,
endY: r.endY + dy,
}))
);
} else if (dragging >= 0) {
const updatedTables = props.tables.map((t) => {
if (t.id === dragging) {