From 2e575762007acba15be4978f14ed8b66f2e681e3 Mon Sep 17 00:00:00 2001 From: /home/neo <158327205+neoapps-dev@users.noreply.github.com> Date: Fri, 26 Jun 2026 21:47:01 +0300 Subject: [PATCH] feat(intro): skip on keypress or click (#92) --- src/components/common/CinematicIntro.tsx | 38 +++++++++++++++++------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/components/common/CinematicIntro.tsx b/src/components/common/CinematicIntro.tsx index ccceaeb..1889c2c 100644 --- a/src/components/common/CinematicIntro.tsx +++ b/src/components/common/CinematicIntro.tsx @@ -1,13 +1,11 @@ -import { useState, useEffect } from "react"; +import { useState, useEffect, useRef } from "react"; import { motion, AnimatePresence } from "framer-motion"; - interface CinematicIntroProps { onComplete: () => void; startMusic: () => void; } type Phase = "black" | "white-lceteam" | "white-esrb" | "out"; - const TIMINGS = { black: 800, "white-lceteam": 3000, @@ -15,31 +13,49 @@ const TIMINGS = { out: 800, }; -export function CinematicIntro({ onComplete, startMusic }: CinematicIntroProps) { +export function CinematicIntro({ + onComplete, + startMusic, +}: CinematicIntroProps) { const [phase, setPhase] = useState("black"); + const skipped = useRef(false); + const containerRef = useRef(null); + const skip = () => { + if (skipped.current) return; + skipped.current = true; + onComplete(); + }; useEffect(() => { startMusic(); - const run = async () => { await new Promise((r) => setTimeout(r, TIMINGS.black)); + if (skipped.current) return; setPhase("white-lceteam"); - await new Promise((r) => setTimeout(r, TIMINGS["white-lceteam"])); + if (skipped.current) return; setPhase("white-esrb"); - await new Promise((r) => setTimeout(r, TIMINGS["white-esrb"])); + if (skipped.current) return; setPhase("out"); - await new Promise((r) => setTimeout(r, TIMINGS.out)); + if (skipped.current) return; onComplete(); }; run(); + const container = containerRef.current; + if (container) container.focus(); }, [onComplete, startMusic]); return ( -
+
{phase === "black" && ( )} - {(phase === "white-lceteam" || phase === "white-esrb" || phase === "out") && ( + {(phase === "white-lceteam" || + phase === "white-esrb" || + phase === "out") && (