(notify: () => void)
| 17 | const subscribers = new Set<() => void>(); |
| 18 | let detach: (() => void) | undefined; |
| 19 | function subscribe(notify: () => void): () => void { |
| 20 | if (!subscribers.size) { |
| 21 | const broadcast = () => subscribers.forEach(listener => listener()); |
| 22 | const query = typeof window.matchMedia === 'function' ? window.matchMedia('(prefers-reduced-motion: reduce)') : undefined; |
| 23 | window.addEventListener(CHANGE, broadcast); window.addEventListener('storage', broadcast); |
| 24 | document.addEventListener('visibilitychange', broadcast); query?.addEventListener('change', broadcast); |
| 25 | detach = () => { |
| 26 | window.removeEventListener(CHANGE, broadcast); window.removeEventListener('storage', broadcast); |
| 27 | document.removeEventListener('visibilitychange', broadcast); query?.removeEventListener('change', broadcast); |
| 28 | }; |
| 29 | } |
| 30 | subscribers.add(notify); |
| 31 | return () => { subscribers.delete(notify); if (!subscribers.size) { detach?.(); detach = undefined; } }; |
| 32 | } |
| 33 | const motionSnapshot = () => edgeMotionPreference() && !reducedMotion() && !document.hidden; |
| 34 | export function useEdgeMotion(active = true): boolean { |
| 35 | return useSyncExternalStore(subscribe, motionSnapshot, () => false) && active; |
nothing calls this directly
no outgoing calls
no test coverage detected