From 8879b42b1cddb7002b4585cd3c54d3fbe435c08a Mon Sep 17 00:00:00 2001 From: AliReza Date: Thu, 8 Oct 2026 18:12:35 +0330 Subject: [PATCH] Fix: first screen's looping animations (mascot bob, island ring, start button) never ran until a tab switch; AnimatePresence initial={false} leaked into children --- src/app/MainApp.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/app/MainApp.tsx b/src/app/MainApp.tsx index a0f1c3b..48e7b54 100644 --- a/src/app/MainApp.tsx +++ b/src/app/MainApp.tsx @@ -1,4 +1,4 @@ -import { lazy, Suspense, useEffect, useState, type ComponentType } from 'react'; +import { lazy, Suspense, useEffect, useRef, useState, type ComponentType } from 'react'; import { AnimatePresence, motion } from 'motion/react'; import { CheckCircle2, XCircle } from 'lucide-react'; import { api, type Grade, type UserProfile } from '@/api'; @@ -71,15 +71,22 @@ function Screens({ onSignedOut }: Pick) { const nav = useNav(); const { route } = nav; const showNav = isTab(route.name) && nav.tab === route.name; + // صفحه‌ی اولِ بعد از ورود بی‌انیمیشنِ ورود می‌آید، ولی این را روی خودِ motion.div می‌گذاریم نه + // ``: آن یکی به همه‌ی فرزندهای motionِ صفحه‌ی اول هم سرایت می‌کند و + // انیمیشن‌های تکرارشونده‌شان (ماسکوتِ بالا‌پایین، حلقه‌ی جزیره، دکمه‌ی «شروع») تا اولین تعویضِ تب شروع نمی‌شدند. + const firstRender = useRef(true); + useEffect(() => { + firstRender.current = false; + }, []); return ( <>
- +