Fix fit window

This commit is contained in:
1ilit 2024-02-20 11:32:19 +02:00
parent 47707146b8
commit f38acf24ee
2 changed files with 6 additions and 4 deletions

View File

@ -557,18 +557,20 @@ export default function ControlPanel({
const fitWindow = () => {
const diagram = document.getElementById("diagram").getBoundingClientRect();
const canvas = document.getElementById("canvas").getBoundingClientRect();
console.log(diagram);
console.log(canvas);
const scaleX = canvas.width / diagram.width;
const scaleY = canvas.height / diagram.height;
const scale = Math.min(scaleX, scaleY);
const translateX = canvas.width / 2;
const translateY = canvas.height / 2;
const translateX = canvas.left;
const translateY = canvas.top;
setSettings((prev) => ({
...prev,
zoom: scale,
zoom: scale - 0.01,
pan: { x: translateX, y: translateY },
}));
};

View File

@ -470,7 +470,7 @@ export default function Editor() {
notes.length,
types.length,
relationships.length,
tasks.length,
tasks?.length,
]);
useEffect(() => {