diff --git a/adventskalender/shared/js/position.js b/adventskalender/shared/js/position.js index 1bbe369..4c87385 100644 --- a/adventskalender/shared/js/position.js +++ b/adventskalender/shared/js/position.js @@ -5,8 +5,6 @@ * und positioniert die Elemente exakt auf dem sichtbaren Bild. */ -const SCALE_FACTOR = 0.9; // 0.9 = etwas kleiner, 1.0 = originalgröße - function positionAllDoors() { const cont = document.querySelector('.kalenderbild'); const img = cont?.querySelector('img'); @@ -18,14 +16,14 @@ function positionAllDoors() { document.querySelectorAll('.door').forEach(door => { const topPct = parseFloat(door.dataset.top) || 0; const leftPct = parseFloat(door.dataset.left) || 0; - const widthPct = (parseFloat(door.dataset.width) || 10) * SCALE_FACTOR; + const widthPct = parseFloat(door.dataset.width) || 10; const w = imgRect.width * (widthPct / 100); door.style.position = 'absolute'; door.style.width = w + 'px'; door.style.height = w + 'px'; - door.style.top = (imgRect.top - contRect.top + imgRect.height * (topPct / 100)) + 'px'; - door.style.left = (imgRect.left - contRect.left + imgRect.width * (leftPct / 100)) + 'px'; + door.style.top = (imgRect.height * (topPct / 100)) + 'px'; + door.style.left = (imgRect.width * (leftPct / 100) + (contRect.width - imgRect.width) / 2) + 'px'; }); }