v0.12.0-hotfix2
This commit is contained in:
+17
-14
@@ -365,7 +365,7 @@ function renderFlowSaveStatus() {
|
||||
}
|
||||
|
||||
function setFlowZoom(value, { render = true } = {}) {
|
||||
const next = clamp(Number(value) || 1, .2, 1.35);
|
||||
const next = clamp(Number(value) || 1, .1, 1.35);
|
||||
app.flowZoom = Math.round(next * 20) / 20;
|
||||
const canvas = $('#flowCanvas');
|
||||
if (canvas) canvas.style.zoom = String(app.flowZoom);
|
||||
@@ -379,40 +379,43 @@ function fitFlowToView({ maxZoom = 1 } = {}) {
|
||||
const nodes = app.flowDraft?.nodes || [];
|
||||
if (!workspace || !nodes.length) {
|
||||
setFlowZoom(1);
|
||||
if (workspace) workspace.scrollTo({ left: 0, top: 0, behavior: 'smooth' });
|
||||
if (workspace) workspace.scrollTo({ left: 0, top: 0, behavior: 'auto' });
|
||||
return;
|
||||
}
|
||||
|
||||
const nodeWidth = 170, fallbackHeight = 96, pad = 48;
|
||||
const compactViewport = window.matchMedia('(max-width: 900px), (max-height: 700px)').matches;
|
||||
const nodeWidth = 170, fallbackHeight = 96, pad = compactViewport ? 24 : 48;
|
||||
const bounds = nodes.map(node => {
|
||||
const element = $(`[data-flow-node="${CSS.escape(node.id)}"]`);
|
||||
return {
|
||||
left: Number(node.x || 0),
|
||||
top: Number(node.y || 0),
|
||||
left: Number.isFinite(Number(element?.offsetLeft)) ? Number(element.offsetLeft) : Number(node.x || 0),
|
||||
top: Number.isFinite(Number(element?.offsetTop)) ? Number(element.offsetTop) : Number(node.y || 0),
|
||||
width: Math.max(nodeWidth, Number(element?.offsetWidth || 0)),
|
||||
height: Math.max(fallbackHeight, Number(element?.offsetHeight || 0)),
|
||||
};
|
||||
});
|
||||
const minX = Math.max(0, Math.min(...bounds.map(item => item.left)) - pad);
|
||||
const minY = Math.max(0, Math.min(...bounds.map(item => item.top)) - pad);
|
||||
const minX = Math.min(...bounds.map(item => item.left)) - pad;
|
||||
const minY = Math.min(...bounds.map(item => item.top)) - pad;
|
||||
const maxX = Math.max(...bounds.map(item => item.left + item.width)) + pad;
|
||||
const maxY = Math.max(...bounds.map(item => item.top + item.height)) + pad;
|
||||
const contentW = Math.max(1, maxX - minX), contentH = Math.max(1, maxY - minY);
|
||||
const availableW = Math.max(80, workspace.clientWidth - 20);
|
||||
const availableH = Math.max(80, workspace.clientHeight - 20);
|
||||
const rawZoom = clamp(Math.min(availableW / contentW, availableH / contentH, maxZoom), .2, 1.35);
|
||||
const zoom = Math.max(.2, Math.floor(rawZoom * 20) / 20);
|
||||
const availableW = Math.max(80, workspace.clientWidth - (compactViewport ? 12 : 20));
|
||||
const availableH = Math.max(80, workspace.clientHeight - (compactViewport ? 12 : 20));
|
||||
const minZoom = compactViewport ? .1 : .2;
|
||||
const rawZoom = clamp(Math.min(availableW / contentW, availableH / contentH, maxZoom), minZoom, 1.35);
|
||||
const zoom = Math.max(minZoom, Math.floor(rawZoom * 20) / 20);
|
||||
setFlowZoom(zoom);
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
requestAnimationFrame(() => requestAnimationFrame(() => {
|
||||
const centerX = ((minX + maxX) / 2) * app.flowZoom;
|
||||
const centerY = ((minY + maxY) / 2) * app.flowZoom;
|
||||
workspace.scrollTo({
|
||||
left: Math.max(0, centerX - workspace.clientWidth / 2),
|
||||
top: Math.max(0, centerY - workspace.clientHeight / 2),
|
||||
behavior: 'smooth',
|
||||
behavior: 'auto',
|
||||
});
|
||||
});
|
||||
renderFlowEdges();
|
||||
}));
|
||||
}
|
||||
|
||||
function renderFlowBlockLibrary(filter = '') {
|
||||
|
||||
Reference in New Issue
Block a user