Files
immich-folio/components/PageTransition.tsx

40 lines
848 B
TypeScript

'use client';
import { motion, AnimatePresence } from 'framer-motion';
import { usePathname } from 'next/navigation';
import React from 'react';
interface PageTransitionProps {
children: React.ReactNode;
enabled: boolean;
}
/**
* Provides smooth page transitions using framer-motion.
* Can be toggled on/off via gallery.yaml.
*/
export function PageTransition({ children, enabled }: PageTransitionProps) {
const pathname = usePathname();
if (!enabled) {
return <>{children}</>;
}
return (
<AnimatePresence mode="wait">
<motion.div
key={pathname}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{
duration: 0.3,
ease: 'easeInOut',
}}
>
{children}
</motion.div>
</AnimatePresence>
);
}