This commit is contained in:
2026-04-25 03:35:30 +09:00
parent 45f9dd9b9b
commit c787d4c7ac
2 changed files with 22 additions and 18 deletions
+18 -15
View File
@@ -3,29 +3,32 @@
const header = document.querySelector('header');
if (!header) return;
const STRIPS = 24;
const MAX_BLUR = 16;
const LAYERS = [
{ blur: 1, from: 0, to: 15 },
{ blur: 3, from: 15, to: 35 },
{ blur: 6, from: 35, to: 55 },
{ blur: 10, from: 55, to: 75 },
{ blur: 16, from: 75, to: 95 },
];
const container = document.createElement('div');
container.className = 'header-blur';
container.setAttribute('aria-hidden', 'true');
for (let i = 0; i < STRIPS; i++) {
const strength = 1 - i / (STRIPS - 1);
const blur = MAX_BLUR * Math.pow(strength, 1.6);
const strip = document.createElement('div');
strip.className = 'blur-strip';
strip.style.setProperty('--blur', blur.toFixed(2) + 'px');
strip.style.top = (i * 100 / STRIPS) + '%';
strip.style.height = (100 / STRIPS) + '%';
container.appendChild(strip);
}
LAYERS.forEach(cfg => {
const layer = document.createElement('div');
layer.className = 'blur-layer';
layer.style.setProperty('--blur', cfg.blur + 'px');
layer.style.setProperty(
'--mask',
`linear-gradient(to top, transparent ${cfg.from}%, black ${cfg.to}%)`
);
container.appendChild(layer);
});
header.parentNode.insertBefore(container, header);
const sync = () => {
container.style.height = header.getBoundingClientRect().height + 'px';
};
const sync = () => { container.style.height = header.offsetHeight + 'px'; };
sync();
if ('ResizeObserver' in window) new ResizeObserver(sync).observe(header);
else window.addEventListener('resize', sync);