v0.12.0-hotfix2
This commit is contained in:
+14
-7
@@ -173,6 +173,11 @@ function toggleChartFullscreen(id) {
|
||||
|
||||
card.classList.add('chart-fullscreen-fallback');
|
||||
document.body.classList.add('chart-fullscreen-open');
|
||||
if (window.matchMedia('(max-width: 760px)').matches) {
|
||||
app.chartZooms[id] = 1;
|
||||
canvas.dataset.chartZoom = '1';
|
||||
if (canvas.parentElement) canvas.parentElement.scrollLeft = 0;
|
||||
}
|
||||
updateChartFullscreenButton(card);
|
||||
requestAnimationFrame(() => redrawHistoryChart(id));
|
||||
}
|
||||
@@ -183,11 +188,12 @@ function prepareCanvas(canvas, height) {
|
||||
const wrapWidth = Math.floor(wrap?.clientWidth || rect.width || 720);
|
||||
const card = canvas.closest('.history-chart-card');
|
||||
const fullscreen = chartCardIsFullscreen(card);
|
||||
const fullscreenHeight = fullscreen ? Math.floor(wrap?.clientHeight || 0) : 0;
|
||||
const actualHeight = fullscreenHeight || height;
|
||||
const zoom = clamp(Number(canvas.dataset.chartZoom || 1), 1, 4);
|
||||
// Regular charts keep a useful minimum plotting width and may scroll horizontally.
|
||||
// In fullscreen, 100% zoom must fit the available viewport instead of forcing 720px.
|
||||
const mobileFullscreen = fullscreen && window.matchMedia('(max-width: 760px)').matches;
|
||||
const wrapHeight = fullscreen ? Math.floor(wrap?.clientHeight || 0) : 0;
|
||||
const naturalMobileHeight = Math.round(clamp(wrapWidth * .72, 260, 360));
|
||||
const actualHeight = mobileFullscreen ? Math.min(wrapHeight || naturalMobileHeight, naturalMobileHeight) : (wrapHeight || height);
|
||||
const zoom = clamp(Number(canvas.dataset.chartZoom || 1), 1, MAX_CHART_ZOOM);
|
||||
// Normal charts may scroll horizontally. Fullscreen 100% always fits the viewport width.
|
||||
const baseWidth = fullscreen ? Math.max(1, wrapWidth) : Math.max(720, wrapWidth);
|
||||
const width = Math.max(1, Math.floor(baseWidth * zoom));
|
||||
const dpr = window.devicePixelRatio || 1;
|
||||
@@ -449,7 +455,8 @@ function drawLineChart(canvas, series, rows, { height = 340, minValue = null, ma
|
||||
const { ctx, width } = prepared;
|
||||
height = prepared.height;
|
||||
const text = cssColor('--muted', '#888'), grid = cssColor('--grid', '#333');
|
||||
const pad = { left: 54, right: 20, top: 20, bottom: 42 };
|
||||
const compactPlot = width < 520;
|
||||
const pad = compactPlot ? { left: 43, right: 12, top: 16, bottom: 34 } : { left: 54, right: 20, top: 20, bottom: 42 };
|
||||
const allValues = [];
|
||||
visibleSeries.forEach(item => sortedRows.forEach(row => { const value = item.value(row); if (Number.isFinite(value)) allValues.push(value); }));
|
||||
if (!allValues.length) return drawEmptyChart(canvas, height);
|
||||
@@ -467,7 +474,7 @@ function drawLineChart(canvas, series, rows, { height = 340, minValue = null, ma
|
||||
ctx.beginPath(); ctx.moveTo(pad.left, py); ctx.lineTo(width - pad.right, py); ctx.stroke();
|
||||
ctx.textAlign = 'right'; ctx.fillText(binaryLabels ? value.toFixed(0) : `${value.toFixed(1)}°`, pad.left - 8, py + 3);
|
||||
}
|
||||
const ticks = 5;
|
||||
const ticks = width < 420 ? 2 : width < 620 ? 3 : 5;
|
||||
for (let i = 0; i <= ticks; i++) {
|
||||
const idx = Math.min(sortedRows.length - 1, Math.round(i * (sortedRows.length - 1) / ticks)); const px = x(sortedRows[idx]);
|
||||
ctx.textAlign = 'center'; ctx.fillText(timeLabel(sortedRows[idx].timestamp, $('#historyHours')?.value), px, height - 14);
|
||||
|
||||
+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