Fix palm trees 2

This commit is contained in:
2026-05-02 12:33:00 +07:00
parent 559a2e9132
commit cd241981b4

View File

@@ -170,6 +170,31 @@ function initFilters() {
});
}
// ---- Palm fronds: lock sizes to px at load so vw doesn't recalculate on mobile scroll ----
function lockPalmSizes() {
const vw = window.innerWidth;
const sizes = {
'corner-tl': Math.min(Math.max(vw * 0.40, 100), 620),
'corner-tr': Math.min(Math.max(vw * 0.40, 100), 620),
'corner-bl': Math.min(Math.max(vw * 0.40, 100), 620),
'corner-br': Math.min(Math.max(vw * 0.40, 100), 620),
'corner-ml': Math.min(Math.max(vw * 0.49, 120), 760),
'corner-ml2': Math.min(Math.max(vw * 0.45, 110), 700),
'corner-mr': Math.min(Math.max(vw * 0.44, 110), 680),
'corner-mr2': Math.min(Math.max(vw * 0.48, 115), 740),
};
document.querySelectorAll('.sfB-palm').forEach(el => {
for (const cls of el.classList) {
if (sizes[cls] !== undefined) {
const px = sizes[cls] + 'px';
el.style.width = px;
el.style.height = px;
break;
}
}
});
}
// ---- Init ----
document.addEventListener('DOMContentLoaded', () => {
initNav();
@@ -178,4 +203,5 @@ document.addEventListener('DOMContentLoaded', () => {
initFilters();
const yearEl = document.getElementById('footer-year');
if (yearEl) yearEl.textContent = new Date().getFullYear();
lockPalmSizes();
});