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

20 lines
678 B
JavaScript

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 };