- 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
23 lines
594 B
TypeScript
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);
|
|
}
|