From 75d74967f4125ece9c40c3a1878956a59659b33f Mon Sep 17 00:00:00 2001 From: mert ozen Date: Tue, 7 Oct 2025 10:04:35 +0300 Subject: [PATCH] Add legacy matchMedia.addListener support for older Safari versions --- packages/framer-motion/src/utils/reduced-motion/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/framer-motion/src/utils/reduced-motion/index.ts b/packages/framer-motion/src/utils/reduced-motion/index.ts index b6cbe47bff..f3b5f27335 100644 --- a/packages/framer-motion/src/utils/reduced-motion/index.ts +++ b/packages/framer-motion/src/utils/reduced-motion/index.ts @@ -11,7 +11,11 @@ export function initPrefersReducedMotion() { const setReducedMotionPreferences = () => (prefersReducedMotion.current = motionMediaQuery.matches) - motionMediaQuery.addEventListener("change", setReducedMotionPreferences) + if (motionMediaQuery.addEventListener) { + motionMediaQuery.addEventListener("change", setReducedMotionPreferences) + } else { + motionMediaQuery.addListener(setReducedMotionPreferences) + } setReducedMotionPreferences() } else {