Fix palm trees 3

This commit is contained in:
2026-05-02 12:35:11 +07:00
parent cd241981b4
commit f7d44cb26a

View File

@@ -170,27 +170,35 @@ function initFilters() {
});
}
// ---- Palm fronds: lock sizes to px at load so vw doesn't recalculate on mobile scroll ----
// ---- Palm fronds: lock sizes AND positions to px at load so nothing recalculates 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),
const vh = window.innerHeight;
const clamp = (val, min, max) => Math.min(Math.max(val, min), max);
// Each entry: [size, { top|bottom, left|right } in px]
const config = {
'corner-tl': { size: clamp(vw * 0.40, 100, 620), pos: { top: vh * -0.08, left: vw * -0.10 } },
'corner-tr': { size: clamp(vw * 0.40, 100, 620), pos: { top: vh * -0.08, right: vw * -0.10 } },
'corner-bl': { size: clamp(vw * 0.40, 100, 620), pos: { bottom: vh * -0.08, left: vw * -0.10 } },
'corner-br': { size: clamp(vw * 0.40, 100, 620), pos: { bottom: vh * -0.08, right: vw * -0.10 } },
'corner-ml': { size: clamp(vw * 0.49, 120, 760), pos: { top: vh * 0.32, left: vw * -0.08 } },
'corner-ml2': { size: clamp(vw * 0.45, 110, 700), pos: { top: vh * 0.62, left: vw * -0.10 } },
'corner-mr': { size: clamp(vw * 0.44, 110, 680), pos: { top: vh * 0.22, right: vw * -0.10 } },
'corner-mr2': { size: clamp(vw * 0.48, 115, 740), pos: { top: vh * 0.70, right: vw * -0.07 } },
};
document.querySelectorAll('.sfB-palm').forEach(el => {
for (const cls of el.classList) {
if (sizes[cls] !== undefined) {
const px = sizes[cls] + 'px';
const cfg = config[cls];
if (!cfg) continue;
const px = cfg.size + 'px';
el.style.width = px;
el.style.height = px;
break;
for (const [prop, val] of Object.entries(cfg.pos)) {
el.style[prop] = val + 'px';
}
break;
}
});
}