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() {
|
||||
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';
|
||||
el.style.width = px;
|
||||
el.style.height = px;
|
||||
break;
|
||||
const cfg = config[cls];
|
||||
if (!cfg) continue;
|
||||
const px = cfg.size + 'px';
|
||||
el.style.width = px;
|
||||
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