diff --git a/src/components/common/PageTransition.tsx b/src/components/common/PageTransition.tsx index 3e5a5b4..de90795 100644 --- a/src/components/common/PageTransition.tsx +++ b/src/components/common/PageTransition.tsx @@ -95,6 +95,19 @@ export function PageTransition({ ? getTransitionVariant(currentLayerPathname ?? '', location.pathname) : 'vertical'; + const shouldSkipExitLayer = (() => { + if (transitionVariantRef.current !== 'ios' || nextDirection !== 'backward') return false; + const normalizeSegments = (pathname: string) => + pathname + .split('/') + .filter(Boolean) + .filter((segment) => segment.length > 0); + const fromSegments = normalizeSegments(currentLayerPathname ?? ''); + const toSegments = normalizeSegments(location.pathname); + if (!fromSegments.length || !toSegments.length) return false; + return fromSegments[0] === toSegments[0] && toSegments.length === 1; + })(); + setLayers((prev) => { const variant = transitionVariantRef.current; const direction = transitionDirectionRef.current; @@ -135,13 +148,22 @@ export function PageTransition({ }; }); - const exitingLayer: Layer = { ...previousCurrent, status: 'exiting' }; + if (shouldSkipExitLayer) { + nextLayersRef.current = targetStack; + return targetStack; + } + const exitingLayer: Layer = { ...previousCurrent, status: 'exiting' }; nextLayersRef.current = targetStack; return [...targetStack, exitingLayer]; } } + if (shouldSkipExitLayer) { + nextLayersRef.current = [nextCurrent]; + return [nextCurrent]; + } + const exitingLayer: Layer = { ...previousCurrent, status: 'exiting' }; nextLayersRef.current = [nextCurrent];