From b17ad3a341d6c4dc7b7f752a193b6745ff3b50e2 Mon Sep 17 00:00:00 2001 From: Thomas Dannenberg Date: Tue, 4 Nov 2025 20:56:55 +0000 Subject: [PATCH] adventskalender/shared/js/position.js aktualisiert --- adventskalender/shared/js/position.js | 29 +++++++++++++-------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/adventskalender/shared/js/position.js b/adventskalender/shared/js/position.js index 3a4d561..c557bc6 100644 --- a/adventskalender/shared/js/position.js +++ b/adventskalender/shared/js/position.js @@ -47,23 +47,22 @@ function positionAllDoors() { }); // Openfields - document.querySelectorAll('.openfield').forEach(field => { - const day = field.dataset.day; - const topPct = parseFloat(field.dataset.top) || 0; - const leftPct = parseFloat(field.dataset.left) || 0; - const widthPct = parseFloat(field.dataset.width) || 10; + // Openfields +document.querySelectorAll('.openfield').forEach(field => { + const day = field.dataset.day; + const topPct = parseFloat(field.dataset.top) || 0; + const leftPct = parseFloat(field.dataset.left) || 0; + const widthPct = parseFloat(field.dataset.width) || 10; - const w = imgRect.width * (widthPct / 100); - const h = (document.querySelector(`.fluegel[data-day="${day}"]`)) - ? w * 2 // Doppelt so hoch bei Flügeltür - : w; // Quadratisch bei normaler Tür + const w = imgRect.width * (widthPct / 100); + const h = w; // Immer quadratisch – egal ob Tür oder Flügeltür - field.style.position = 'absolute'; - field.style.width = w + 'px'; - field.style.height = h + 'px'; - field.style.top = (imgRect.top - contRect.top + imgRect.height * (topPct / 100)) + 'px'; - field.style.left = (imgRect.width * (leftPct / 100) + (contRect.width - imgRect.width) / 2) + 'px'; - }); + field.style.position = 'absolute'; + field.style.width = w + 'px'; + field.style.height = h + 'px'; + field.style.top = (imgRect.top - contRect.top + imgRect.height * (topPct / 100)) + 'px'; + field.style.left = (imgRect.width * (leftPct / 100) + (contRect.width - imgRect.width) / 2) + 'px'; +}); } window.addEventListener('load', positionAllDoors);