adventskalender/shared/js/position.js aktualisiert
This commit is contained in:
@@ -32,7 +32,6 @@ function positionAllDoors() {
|
|||||||
// Flügel-Türen (linker + rechter Flügel)
|
// Flügel-Türen (linker + rechter Flügel)
|
||||||
document.querySelectorAll('.fluegel').forEach(fluegel => {
|
document.querySelectorAll('.fluegel').forEach(fluegel => {
|
||||||
const day = fluegel.dataset.day;
|
const day = fluegel.dataset.day;
|
||||||
const side = fluegel.classList.contains('left') ? 'left' : 'right';
|
|
||||||
const topPct = parseFloat(fluegel.dataset.top) || 0;
|
const topPct = parseFloat(fluegel.dataset.top) || 0;
|
||||||
const leftPct = parseFloat(fluegel.dataset.left) || 0;
|
const leftPct = parseFloat(fluegel.dataset.left) || 0;
|
||||||
const widthPct = parseFloat(fluegel.dataset.width) || 10;
|
const widthPct = parseFloat(fluegel.dataset.width) || 10;
|
||||||
@@ -44,12 +43,7 @@ function positionAllDoors() {
|
|||||||
fluegel.style.width = fluegelWidth + 'px';
|
fluegel.style.width = fluegelWidth + 'px';
|
||||||
fluegel.style.height = fluegelHeight + 'px';
|
fluegel.style.height = fluegelHeight + 'px';
|
||||||
fluegel.style.top = (imgRect.top - contRect.top + imgRect.height * (topPct / 100)) + 'px';
|
fluegel.style.top = (imgRect.top - contRect.top + imgRect.height * (topPct / 100)) + 'px';
|
||||||
|
|
||||||
if (side === 'left') {
|
|
||||||
fluegel.style.left = (imgRect.width * (leftPct / 100) + (contRect.width - imgRect.width) / 2) + 'px';
|
fluegel.style.left = (imgRect.width * (leftPct / 100) + (contRect.width - imgRect.width) / 2) + 'px';
|
||||||
} else {
|
|
||||||
fluegel.style.left = (imgRect.width * (leftPct / 100) + fluegelWidth + (contRect.width - imgRect.width) / 2) + 'px';
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Openfields
|
// Openfields
|
||||||
@@ -59,9 +53,10 @@ function positionAllDoors() {
|
|||||||
const leftPct = parseFloat(field.dataset.left) || 0;
|
const leftPct = parseFloat(field.dataset.left) || 0;
|
||||||
const widthPct = parseFloat(field.dataset.width) || 10;
|
const widthPct = parseFloat(field.dataset.width) || 10;
|
||||||
|
|
||||||
const isFluegel = document.querySelector(`.fluegel.left[data-day="${day}"]`) !== null;
|
|
||||||
const w = imgRect.width * (widthPct / 100);
|
const w = imgRect.width * (widthPct / 100);
|
||||||
const h = isFluegel ? w * 2 : w;
|
const h = (document.querySelector(`.fluegel[data-day="${day}"]`))
|
||||||
|
? w * 2 // Doppelt so hoch bei Flügeltür
|
||||||
|
: w; // Quadratisch bei normaler Tür
|
||||||
|
|
||||||
field.style.position = 'absolute';
|
field.style.position = 'absolute';
|
||||||
field.style.width = w + 'px';
|
field.style.width = w + 'px';
|
||||||
|
|||||||
Reference in New Issue
Block a user