diff --git a/app/intro.tsx b/app/intro.tsx index 63537d2..a2f711f 100644 --- a/app/intro.tsx +++ b/app/intro.tsx @@ -4,6 +4,9 @@ import { useEffect } from "react"; import { usePathname } from "next/navigation"; import gsap from "gsap"; +// Pages qui ont l'écran de chargement (avec/sans slash final selon la config). +const WITH_INTRO = new Set(["/", "/cv", "/cv/"]); + export default function Intro() { const pathname = usePathname(); @@ -12,17 +15,18 @@ export default function Intro() { const reveal = gsap.utils.toArray("[data-reveal]"); const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches; - // No reveal targets (e.g. error / not-found pages) or reduced motion: skip the intro. - if (reduce || reveal.length === 0) { + if (reduce) { gsap.set(overlay, { display: "none" }); return; } - gsap.set(reveal, { autoAlpha: 0, y: 12 }); + if (reveal.length) gsap.set(reveal, { autoAlpha: 0, y: 12 }); const tl = gsap.timeline({ defaults: { ease: "power3.out" }, - onComplete: () => gsap.set(reveal, { clearProps: "all" }), + onComplete: () => { + if (reveal.length) gsap.set(reveal, { clearProps: "all" }); + }, }); tl.to("[data-intro-mark]", { autoAlpha: 1, scale: 1, duration: 0.45, ease: "power2.out" }, 0) @@ -32,17 +36,16 @@ export default function Intro() { { scaleX: 1, duration: 0.85, ease: "power2.inOut" }, 0.1, ) - .to(overlay, { yPercent: -100, duration: 0.5, ease: "power3.inOut" }, ">-0.1") - .to(reveal, { autoAlpha: 1, y: 0, duration: 0.5, stagger: 0.07 }, "<0.2") - .set(overlay, { display: "none" }); + .to(overlay, { yPercent: -100, duration: 0.5, ease: "power3.inOut" }, ">-0.1"); - return () => { - tl.kill(); - gsap.set(reveal, { clearProps: "all" }); - }; + if (reveal.length) { + tl.to(reveal, { autoAlpha: 1, y: 0, duration: 0.5, stagger: 0.07 }, "<0.2"); + } + + tl.set(overlay, { display: "none" }); }, []); - if (pathname !== "/") return null; + if (!WITH_INTRO.has(pathname)) return null; return (