Fix palm trees 3
This commit is contained in:
38
js/main.js
38
js/main.js
@@ -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() {
|
function lockPalmSizes() {
|
||||||
const vw = window.innerWidth;
|
const vw = window.innerWidth;
|
||||||
const sizes = {
|
const vh = window.innerHeight;
|
||||||
'corner-tl': Math.min(Math.max(vw * 0.40, 100), 620),
|
const clamp = (val, min, max) => Math.min(Math.max(val, min), max);
|
||||||
'corner-tr': Math.min(Math.max(vw * 0.40, 100), 620),
|
|
||||||
'corner-bl': Math.min(Math.max(vw * 0.40, 100), 620),
|
// Each entry: [size, { top|bottom, left|right } in px]
|
||||||
'corner-br': Math.min(Math.max(vw * 0.40, 100), 620),
|
const config = {
|
||||||
'corner-ml': Math.min(Math.max(vw * 0.49, 120), 760),
|
'corner-tl': { size: clamp(vw * 0.40, 100, 620), pos: { top: vh * -0.08, left: vw * -0.10 } },
|
||||||
'corner-ml2': Math.min(Math.max(vw * 0.45, 110), 700),
|
'corner-tr': { size: clamp(vw * 0.40, 100, 620), pos: { top: vh * -0.08, right: vw * -0.10 } },
|
||||||
'corner-mr': Math.min(Math.max(vw * 0.44, 110), 680),
|
'corner-bl': { size: clamp(vw * 0.40, 100, 620), pos: { bottom: vh * -0.08, left: vw * -0.10 } },
|
||||||
'corner-mr2': Math.min(Math.max(vw * 0.48, 115), 740),
|
'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 => {
|
document.querySelectorAll('.sfB-palm').forEach(el => {
|
||||||
for (const cls of el.classList) {
|
for (const cls of el.classList) {
|
||||||
if (sizes[cls] !== undefined) {
|
const cfg = config[cls];
|
||||||
const px = sizes[cls] + 'px';
|
if (!cfg) continue;
|
||||||
el.style.width = px;
|
const px = cfg.size + 'px';
|
||||||
el.style.height = px;
|
el.style.width = px;
|
||||||
break;
|
el.style.height = px;
|
||||||
|
for (const [prop, val] of Object.entries(cfg.pos)) {
|
||||||
|
el.style[prop] = val + 'px';
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user