fix(ui): stretch canvases to viewport

main
AlexsandrSnytkin 3 hours ago
parent 87f468bfd8
commit 96ba90e423

@ -2225,13 +2225,19 @@ HTML = """<!doctype html>
function configTemplateKey(block) { function configTemplateKey(block) {
return block.dataset.custom === 'true' ? (block.dataset.template || 'source') : block.dataset.section; return block.dataset.custom === 'true' ? (block.dataset.template || 'source') : block.dataset.section;
} }
function canvasViewportFloor(canvas, fallback) {
if (!canvas) return fallback;
const top = Math.max(0, canvas.getBoundingClientRect().top);
return Math.max(fallback, Math.ceil(window.innerHeight - top + 12));
}
function updateConfigCanvasHeight() { function updateConfigCanvasHeight() {
if (!configCanvas) return; if (!configCanvas) return;
const bottom = configBlocks.reduce((value, block) => { const bottom = configBlocks.reduce((value, block) => {
if (configBlockState(block)) return value; if (configBlockState(block)) return value;
return Math.max(value, (block.offsetTop || 0) + block.offsetHeight); return Math.max(value, (block.offsetTop || 0) + block.offsetHeight);
}, 0); }, 0);
configCanvas.style.minHeight = `${Math.max(window.innerWidth <= 760 ? 900 : 760, bottom + 28)}px`; const floor = canvasViewportFloor(configCanvas, window.innerWidth <= 760 ? 900 : 760);
configCanvas.style.minHeight = `${Math.max(floor, bottom + 28)}px`;
} }
function fitConfigBlockContent(block) { function fitConfigBlockContent(block) {
if (!block || configBlockState(block) || block._configManualHeight) return false; if (!block || configBlockState(block) || block._configManualHeight) return false;
@ -3048,7 +3054,8 @@ HTML = """<!doctype html>
function updateNetworkCanvasHeight() { function updateNetworkCanvasHeight() {
if (!networkCanvas) return; if (!networkCanvas) return;
const bottom = networkBlocks.reduce((value, block) => networkState(block) ? value : Math.max(value, (block.offsetTop || 0) + block.offsetHeight), 0); const bottom = networkBlocks.reduce((value, block) => networkState(block) ? value : Math.max(value, (block.offsetTop || 0) + block.offsetHeight), 0);
networkCanvas.style.minHeight = `${Math.max(window.innerWidth <= 760 ? 900 : 720, bottom + 28)}px`; const floor = canvasViewportFloor(networkCanvas, window.innerWidth <= 760 ? 900 : 720);
networkCanvas.style.minHeight = `${Math.max(floor, bottom + 28)}px`;
} }
function applyNetworkLayout() { function applyNetworkLayout() {
if (!networkCanvas) return; if (!networkCanvas) return;

Loading…
Cancel
Save