diff --git a/apps/nowait-user/src/components/layout/PageTransitionWrapper.tsx b/apps/nowait-user/src/components/layout/PageTransitionWrapper.tsx index 51b4b322..ccedc1e3 100644 --- a/apps/nowait-user/src/components/layout/PageTransitionWrapper.tsx +++ b/apps/nowait-user/src/components/layout/PageTransitionWrapper.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useRef } from "react"; +import React, { useRef } from "react"; import "./transition.css"; import { TransitionGroup, CSSTransition } from "react-transition-group"; import { useNavigationType } from "react-router-dom"; @@ -21,13 +21,14 @@ const PageTransitionWrapper = ({ location, children }: PropsType) => { const pathname = location.pathname; const isBack = location.state?.isBack as boolean | undefined; console.log(isBack, "이즈백"); + //라우터 이동 방향에 따른 애니메이션 분리 const isNavigatePush = navigateType === "PUSH" && !isBack; - const isNavigatePop = navigateType === "POP" || isBack; - const isNavigateReplace = navigateType === "REPLACE"; + const isNavigateReplace = navigateType === "REPLACE" && !isBack; + const isAnimation = () => { if (isNavigatePush) return "navigate-push"; - if (isNavigatePop) return "navigate-pop"; + if (isBack) return "navigate-pop"; if (isNavigateReplace) return ""; return ""; }; @@ -41,11 +42,6 @@ const PageTransitionWrapper = ({ location, children }: PropsType) => { const currentNodeRef = nodeRefs.current[pathname]; - useEffect(() => { - if (isNavigatePush || isNavigatePop) { - window.scrollTo(0, 0); - } - }, [pathname, isNavigatePush, isNavigatePop]); return ( ( const Router = () => { const location = useLocation(); return ( - {/* 공개 라우트 - 인증 불필요 */} } /> @@ -84,7 +82,6 @@ const Router = () => { } /> } /> - ); };