securityos/node_modules/framer-motion/dist/es/utils/reduced-motion/index.mjs

20 lines
678 B
JavaScript
Raw Permalink Normal View History

2024-09-06 15:32:35 +00:00
import { isBrowser } from '../is-browser.mjs';
import { hasReducedMotionListener, prefersReducedMotion } from './state.mjs';
function initPrefersReducedMotion() {
hasReducedMotionListener.current = true;
if (!isBrowser)
return;
if (window.matchMedia) {
const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
const setReducedMotionPreferences = () => (prefersReducedMotion.current = motionMediaQuery.matches);
motionMediaQuery.addListener(setReducedMotionPreferences);
setReducedMotionPreferences();
}
else {
prefersReducedMotion.current = false;
}
}
export { initPrefersReducedMotion };