Client: no 'use client' on barrels, lazy lightbox viewer, rAF table of contents, Turnstile polling stops, reduced motion, Media eager, 404 placeholder option

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 13:51:39 +01:00
co-authored by Claude Opus 5.5
parent 1d6108765c
commit 21073d98d0
17 changed files with 72 additions and 38 deletions
+14 -4
View File
@@ -49,11 +49,21 @@ export function TableOfContents({ classNames: cn = {}, items, label, offset = 0.
setActive(current)
}
update()
window.addEventListener('scroll', update, { passive: true })
window.addEventListener('resize', update)
// At most one measurement per frame: a scroll fires many events between two paints, and each one read the
// position of every heading (forced layout on the main thread, which delays the next tap — INP).
let frame = 0
const schedule = () => {
if (!frame) {frame = requestAnimationFrame(() => {
frame = 0
update()
})}
}
window.addEventListener('scroll', schedule, { passive: true })
window.addEventListener('resize', schedule)
return () => {
window.removeEventListener('scroll', update)
window.removeEventListener('resize', update)
cancelAnimationFrame(frame)
window.removeEventListener('scroll', schedule)
window.removeEventListener('resize', schedule)
}
}, [items, offset])