mirror of
https://github.com/hanzoai/site.git
synced 2026-11-20 21:14:28 +00:00
Describe the live catalog, the plan ladder, the open-source read, the Sigil maths, the tilt and the sound kit with real types. Sound is now off until the visitor sets localStorage hz-sound to "on". Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk
17 lines
1.1 KiB
TypeScript
17 lines
1.1 KiB
TypeScript
// Scroll helpers that work the same with or without Lenis (components/Chrome.jsx runs Lenis unless reduced motion).
|
|
// HOW TO USE: import { scrollToEl, scrollToY } from '../lib/scroll'; scrollToEl(el, { offset: -110 })
|
|
// The offset clears Hanzo's 60 px sticky header; reduced motion jumps instead of gliding.
|
|
const calm = () => typeof matchMedia !== 'undefined' && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
|
|
export function scrollToY(y: number, { duration = 1.1, immediate = false }: { duration?: number; immediate?: boolean } = {}) {
|
|
const l = typeof window !== 'undefined' && window.__lenis;
|
|
if (l) l.scrollTo(y, { duration, immediate: immediate || calm(), force: true });
|
|
else window.scrollTo({ top: y, behavior: immediate || calm() ? 'auto' : 'smooth' });
|
|
}
|
|
|
|
export function scrollToEl(el: Element | null | undefined, { offset = -80, duration, immediate }: { offset?: number; duration?: number; immediate?: boolean } = {}) {
|
|
if (!el) return;
|
|
const y = el.getBoundingClientRect().top + window.scrollY + offset;
|
|
scrollToY(y, { duration, immediate });
|
|
}
|