From c445bbcd82d6399654234747fb30633595aa75d3 Mon Sep 17 00:00:00 2001 From: Thomas Dannenberg Date: Tue, 4 Nov 2025 17:46:27 +0000 Subject: [PATCH] adventskalender/shared/js/position.js aktualisiert --- adventskalender/shared/js/position.js | 28 +++++---------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/adventskalender/shared/js/position.js b/adventskalender/shared/js/position.js index 92c358b..0e9c5c8 100644 --- a/adventskalender/shared/js/position.js +++ b/adventskalender/shared/js/position.js @@ -1,10 +1,3 @@ -/** - * Bratonien Adventskalender – Türchen-Positionierung (2025) - * --------------------------------------------------------- - * Liest data-top / data-left / data-width aus jedem Element - * und positioniert .door, .fluegel, .openfield korrekt über dem Bild. - */ - function positionAllDoors() { const cont = document.querySelector('.kalenderbild'); const img = cont?.querySelector('img'); @@ -29,14 +22,14 @@ function positionAllDoors() { el.style.left = (imgRect.width * (leftPct / 100) + (contRect.width - imgRect.width) / 2) + 'px'; }); - // Flügel: jeweils halbe Breite, doppelte Höhe (nicht quadratisch!) + // Flügel: data-width = bereits halbe Breite → NICHT nochmal teilen! document.querySelectorAll('.fluegel').forEach(fluegel => { const topPct = parseFloat(fluegel.dataset.top) || 0; const leftPct = parseFloat(fluegel.dataset.left) || 0; - const widthPct = parseFloat(fluegel.dataset.width) || 10; + const widthPct = parseFloat(fluegel.dataset.width) || 5; - const widthPx = imgRect.width * (widthPct / 100) / 2; - const heightPx = widthPx * 2; + const widthPx = imgRect.width * (widthPct / 100); + const heightPx = widthPx * 2; // volle Türhöhe fluegel.style.position = 'absolute'; fluegel.style.width = widthPx + 'px'; @@ -44,15 +37,4 @@ function positionAllDoors() { fluegel.style.top = (imgRect.top - contRect.top + imgRect.height * (topPct / 100)) + 'px'; fluegel.style.left = (imgRect.width * (leftPct / 100) + (contRect.width - imgRect.width) / 2) + 'px'; }); -} - -window.addEventListener('load', positionAllDoors); -window.addEventListener('resize', positionAllDoors); -window.addEventListener('orientationchange', () => { - setTimeout(positionAllDoors, 300); -}); -document.addEventListener('visibilitychange', () => { - if (document.visibilityState === 'visible') { - setTimeout(positionAllDoors, 200); - } -}); \ No newline at end of file +} \ No newline at end of file