Skip to content

Commit bcc46b6

Browse files
author
jacquesbach
committed
Auto Resize for Forecast Card
1 parent 2037d1a commit bcc46b6

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

static/css/style.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,9 @@
168168
}
169169

170170
.grid-stack-item-content {
171-
overflow-x: hidden;
172-
overflow-y: auto;
171+
xoverflow-x: hidden;
172+
xoverflow-y: auto;
173+
overflow: visible !important;
173174
background: transparent !important;
174175
box-shadow: none !important;
175176
}

static/js/layout.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,41 @@ async function resetDatabaseLayout() {
8585
}
8686
}
8787

88+
function initAutoResizeForCard(cardId) {
89+
90+
const gridItem = document.getElementById(cardId);
91+
const content = gridItem.querySelector(".card");
92+
93+
if (!gridItem || !content) return;
94+
95+
let resizeTimeout;
96+
97+
const observer = new ResizeObserver(() => {
98+
99+
// kleines Debounce (wichtig wegen Chart.js Render-Zyklen)
100+
clearTimeout(resizeTimeout);
101+
102+
resizeTimeout = setTimeout(() => {
103+
104+
const newHeightPx = content.scrollHeight;
105+
106+
const cellHeight = dashboardGrid.getCellHeight();
107+
const newGridHeight = Math.ceil(newHeightPx / cellHeight);
108+
109+
dashboardGrid.update(gridItem, { h: newGridHeight });
110+
111+
}, 80); // Sweet Spot
112+
113+
});
114+
115+
observer.observe(content);
116+
}
117+
88118
document.addEventListener("DOMContentLoaded", async () => {
89119
// --- PHASE 1: Das Gerüst aufbauen ---
90120
initGridstack();
91121
await loadLayout(); // Wartet, bis Boxen aus DB oder LocalStorage da sind
122+
initAutoResizeForCard("card-forecast");
92123

93124
// --- PHASE 2: Startwerte für Datumsfelder setzen ---
94125
const t = new Date().toISOString().split('T')[0];

0 commit comments

Comments
 (0)