Files
Mann_Li_FO/public/lib/useReducedMotion.ts
defiQUG 680ceb4ea3 Mann Li FO: cinematic public site (Next.js static export), pnpm, Gitea CI
- public/: App Router, GSAP lineage corridor, R3F globe, IA routes, 曼李.com metadata
- CONTENT_GATES.md, DEPLOY.md (Cloudflare, NPMplus, Phoenix)
- .gitea/workflows/build-public.yml for static build artifact

Made-with: Cursor
2026-03-30 04:41:00 -07:00

23 lines
594 B
TypeScript

"use client";
import { useSyncExternalStore } from "react";
function subscribe(onChange: () => void) {
const mq = window.matchMedia("(prefers-reduced-motion: reduce)");
mq.addEventListener("change", onChange);
return () => mq.removeEventListener("change", onChange);
}
function getSnapshot() {
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
}
function getServerSnapshot() {
return false;
}
/** Client-only preference; server assumes false. */
export function useReducedMotion() {
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
}