From 81526c9f861a0aa5ec6175358622032a9d3cf1d3 Mon Sep 17 00:00:00 2001 From: data Date: Fri, 20 Feb 2026 12:15:39 +0100 Subject: [PATCH] Fix panel height calculation for multiple carriers Panel height was being cut off when multiple Hutschienen were added. Corrected the height formula to properly account for: - Top margin for main busbars - Full block height for equipment - Spacing between carriers - Bottom margin Co-Authored-By: Claude Opus 4.5 --- js/kundenkarte.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/js/kundenkarte.js b/js/kundenkarte.js index effe147..61054ca 100755 --- a/js/kundenkarte.js +++ b/js/kundenkarte.js @@ -6212,8 +6212,15 @@ // Panel width includes: left margin for label (60px) + rail overhang (30px) + TE width + rail overhang (30px) + padding var panelWidth = 60 + 30 + maxTE * self.TE_WIDTH + 30 + self.PANEL_PADDING; - // Use calculatedTopMargin for dynamic spacing - var panelHeight = self.calculatedTopMargin + self.BLOCK_HEIGHT + 20 + panelCarriers.length * self.RAIL_SPACING + self.BOTTOM_MARGIN; + // Panel height calculation: + // - calculatedTopMargin: space for main busbars at top + // - BLOCK_HEIGHT/2: half block above first rail + // - (carriers-1) * RAIL_SPACING: spacing between rails + // - BLOCK_HEIGHT/2: half block below last rail + // - BOTTOM_MARGIN: margin at bottom + // Simplified: calculatedTopMargin + BLOCK_HEIGHT + (carriers * RAIL_SPACING) + BOTTOM_MARGIN + var carrierCount = Math.max(panelCarriers.length, 1); + var panelHeight = self.calculatedTopMargin + self.BLOCK_HEIGHT + (carrierCount * self.RAIL_SPACING) + self.BOTTOM_MARGIN; panel._x = totalWidth; panel._width = panelWidth; @@ -6233,7 +6240,7 @@ if ((c.total_te || 12) > fallbackMaxTE) fallbackMaxTE = c.total_te; }); totalWidth = fallbackMaxTE * self.TE_WIDTH + 150; - totalHeight = self.calculatedTopMargin + self.BLOCK_HEIGHT + 20 + this.carriers.length * self.RAIL_SPACING + self.BOTTOM_MARGIN; + totalHeight = self.calculatedTopMargin + self.BLOCK_HEIGHT + (this.carriers.length * self.RAIL_SPACING) + self.BOTTOM_MARGIN; } this.layoutWidth = Math.max(totalWidth, 800);