diff --git a/src/components/PillNav.tsx b/src/components/PillNav.tsx index 2e6ca1a..2e60b98 100644 --- a/src/components/PillNav.tsx +++ b/src/components/PillNav.tsx @@ -52,6 +52,8 @@ const PillNav: React.FC = ({ const logoRef = useRef(null); const isInitialMount = useRef(true); + const hasPlayedIntro = useRef(false); + const [introTick, setIntroTick] = useState(0); // --- 1. Gestion du Menu Mobile avec GSAP --- useEffect(() => { @@ -207,7 +209,8 @@ const PillNav: React.FC = ({ document.fonts.ready.then(layout).catch(() => {}); } - if (initialLoadAnimation) { + if (initialLoadAnimation && !hasPlayedIntro.current) { + hasPlayedIntro.current = true; const logo = logoRef.current; const navItems = navItemsRef.current; if (logo) { @@ -221,7 +224,18 @@ const PillNav: React.FC = ({ } return () => window.removeEventListener("resize", onResize); - }, [items, ease, initialLoadAnimation]); + }, [items, ease, initialLoadAnimation, introTick]); + + useEffect(() => { + const onPageShow = (event: PageTransitionEvent) => { + if (event.persisted) { + hasPlayedIntro.current = false; + setIntroTick((t) => t + 1); + } + }; + window.addEventListener("pageshow", onPageShow); + return () => window.removeEventListener("pageshow", onPageShow); + }, []); const handleEnter = (i: number) => { const tl = tlRefs.current[i];