mirror of
https://github.com/lingke-net/koring-space.git
synced 2026-09-12 05:45:17 +08:00
23 lines
571 B
TypeScript
23 lines
571 B
TypeScript
"use client";
|
|||
|
|
|
||
|
|
import { usePathname } from "next/navigation";
|
||
|
|
import { AnimatePresence, motion } from "motion/react";
|
||
|
|
|
||
|
|
export function PageTransition({ children }: { children: React.ReactNode }) {
|
||
|
|
const pathname = usePathname();
|
||
|
|
|
||
|
|
return (
|
||
|
|
<AnimatePresence mode="wait">
|
||
|
|
<motion.div
|
||
|
|
key={pathname}
|
||
|
|
initial={{ opacity: 0, x: 40 }}
|
||
|
|
animate={{ opacity: 1, x: 0 }}
|
||
|
|
exit={{ opacity: 0, x: -40 }}
|
||
|
|
transition={{ duration: 0.25, ease: "easeInOut" }}
|
||
|
|
>
|
||
|
|
{children}
|
||
|
|
</motion.div>
|
||
|
|
</AnimatePresence>
|
||
|
|
);
|
||
|
|
}
|