Skip to content

Instantly share code, notes, and snippets.

@ljaxferrand
Created July 19, 2022 19:43
Show Gist options
  • Save ljaxferrand/2f1cd2664de89ca06d291bfac856bdaf to your computer and use it in GitHub Desktop.
Save ljaxferrand/2f1cd2664de89ca06d291bfac856bdaf to your computer and use it in GitHub Desktop.
Framer Motion: Respect user motion prefs
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