adventskalender/shared/js/position.js aktualisiert

This commit is contained in:
2025-11-04 17:41:52 +00:00
parent 4e57b9d406
commit 9e6bf3431f

View File

@@ -46,15 +46,22 @@ function positionAllElements() {
const leftPct = parseFloat(flugel.dataset.left) || 0; const leftPct = parseFloat(flugel.dataset.left) || 0;
const widthPct = parseFloat(flugel.dataset.width) || 5; const widthPct = parseFloat(flugel.dataset.width) || 5;
const w = imgRect.width * (widthPct / 100); const fullW = imgRect.width * (widthPct / 100);
const w = fullW / 2;
const h = fullW; // volle Türhöhe = Breite der gesamten Tür
const t = imgRect.top - contRect.top + imgRect.height * (topPct / 100); const t = imgRect.top - contRect.top + imgRect.height * (topPct / 100);
const l = imgRect.width * (leftPct / 100) + (contRect.width - imgRect.width) / 2; const l = imgRect.width * (leftPct / 100) + (contRect.width - imgRect.width) / 2;
flugel.style.position = 'absolute'; flugel.style.position = 'absolute';
flugel.style.width = w + 'px'; flugel.style.width = w + 'px';
flugel.style.height = w + 'px'; flugel.style.height = h + 'px';
flugel.style.top = t + 'px'; flugel.style.top = t + 'px';
flugel.style.left = l + 'px';
if (flugel.classList.contains('left')) {
flugel.style.left = l + 'px';
} else if (flugel.classList.contains('right')) {
flugel.style.left = (l + w) + 'px';
}
}); });
} }