const RouteWrapper: React.FC = () => {
const location = useLocation();
return (
<AnimatePresence>
<motion.div
key={location.pathname}
initial={{ opacity: 0.8, scaleX: 1 }}
animate={{ opacity: 1.0, scaleX: 0 }} // X軸方向に縮小
exit={{ opacity: 0.5, scaleX: 0 }} // 元のサイズに戻す
transition={{ duration: 1 }}
style={{
position: "absolute",
top: 0,
left: 0,
width: "100%",
height: "100vh",
backgroundColor: "#E3027E",
zIndex: 10,
transformOrigin: "right", // 縮小時に右端を基準にする
}}
/>
<motion.div
key={location.pathname}
initial={{ opacity: 1 }}
animate={{ opacity: 1 }}
exit={{ opacity: 1 }}
transition={{ duration: 1.5 }}
style={{ position: "relative", width: "100%", height: "100%" }}
>
//適用するコンポーネント
</motion.div>
</AnimatePresence>
);
};