Design overhaul (v1.10.0 to v1.10.2) #18

Merged
ngu-git-admin merged 17 commits from design-overhaul into main 2026-09-30 23:59:16 +01:00
2 changed files with 41 additions and 3 deletions
Showing only changes of commit 6506f65b1e - Show all commits

View file

@ -46,6 +46,13 @@
}
}
/* The same rise where scroll-driven animations are missing: the
scroll position arrives as --pb-y from PageBackdrop.tsx. */
.page-backdrop[data-parallax="script"] .page-backdrop__circle {
transform: translateY(calc(var(--pb-y, 0px) * var(--pb-speed) * -1));
will-change: transform;
}
@keyframes page-backdrop-rise {
to {
transform: translateY(calc(var(--pb-scroll, 0px) * var(--pb-speed) * -1));
@ -53,8 +60,10 @@
}
@media (prefers-reduced-motion: reduce) {
.page-backdrop__circle {
.page-backdrop__circle,
.page-backdrop[data-parallax="script"] .page-backdrop__circle {
animation: none;
transform: none;
}
}

View file

@ -11,8 +11,11 @@
small and quicker at the front, none as fast as the page itself.
The rise is a CSS scroll-driven animation (PageBackdrop.css) over
--pb-scroll, the page's scrollable height, which is measured here
whenever the page changes size (no scroll listener). Without
scroll-driven animations, or under reduced motion, they stay put.
whenever the page changes size. Browsers without scroll-driven
animations (Firefox, for now) get the same motion from a passive
scroll handler instead, which writes the scroll position to one
CSS variable, --pb-y, at most once a frame; the CSS does the rest.
Under reduced motion they stay put either way.
Each page gets its own arrangement: sizes and places come from a
generator seeded with the path, so a page looks the same every
@ -95,6 +98,32 @@ export default function PageBackdrop() {
return () => observer.disconnect()
}, [])
// Where scroll-driven animations are missing: the scroll position,
// once a frame at most, into --pb-y (PageBackdrop.css moves each
// layer by its share of it).
useEffect(() => {
const backdrop = ref.current
if (!backdrop || CSS.supports('animation-timeline: scroll()')) return undefined
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return undefined
backdrop.dataset.parallax = 'script'
let frame = 0
const update = () => {
frame = 0
backdrop.style.setProperty('--pb-y', `${window.scrollY}px`)
}
const onScroll = () => {
if (!frame) frame = requestAnimationFrame(update)
}
update()
window.addEventListener('scroll', onScroll, { passive: true })
return () => {
window.removeEventListener('scroll', onScroll)
cancelAnimationFrame(frame)
delete backdrop.dataset.parallax
}
}, [])
// A new top-level section reaching the window's middle moves the tone on.
useEffect(() => {
const main = document.getElementById('main')