Created
July 19, 2022 19:43
-
-
Save ljaxferrand/2f1cd2664de89ca06d291bfac856bdaf to your computer and use it in GitHub Desktop.
Framer Motion: Respect user motion prefs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { motion, AnimatePresence } from "framer-motion"; | |
import { fadeDown } from "../utils/animations"; | |
import { MotionConfig } from "framer-motion"; | |
import Layout from "../components/Layout"; | |
import "../styles/globals.css"; | |
function MyApp({ Component, pageProps, router }) { | |
return ( | |
<MotionConfig reducedMotion="user"> | |
<Layout currentPath={router.route}> | |
<AnimatePresence exitBeforeEnter> | |
<motion.div | |
key={router.route} | |
initial="initial" | |
animate="animate" | |
exit={{ opacity: 0.25 }} | |
variants={fadeDown} | |
> | |
<Component {...pageProps} /> | |
</motion.div> | |
</AnimatePresence> | |
</Layout> | |
</MotionConfig> | |
); | |
} | |
export default MyApp; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment