From 731353a4a89de948afdc7b493b281e1295296fcc Mon Sep 17 00:00:00 2001 From: Hamid Date: Sat, 16 May 2026 23:40:23 -0700 Subject: [PATCH] fix bug --- src/pages/viewer/components/BookViewer.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pages/viewer/components/BookViewer.tsx b/src/pages/viewer/components/BookViewer.tsx index df19ed0..4dde3cc 100644 --- a/src/pages/viewer/components/BookViewer.tsx +++ b/src/pages/viewer/components/BookViewer.tsx @@ -199,7 +199,11 @@ const BookViewer: FC = ({ pages, catalogSize, documentSettings useEffect(() => { resetEntrance(); - }, [flipKey, pages.length, pages[0]?.id, resetEntrance]); + const frame = requestAnimationFrame(() => { + commitEntranceAtCurrentSpread(); + }); + return () => cancelAnimationFrame(frame); + }, [flipKey, pages.length, pages[0]?.id, resetEntrance, commitEntranceAtCurrentSpread]); // اطمینان از اینکه currentPage همیشه در محدوده معتبر است useEffect(() => { @@ -306,8 +310,10 @@ const BookViewer: FC = ({ pages, catalogSize, documentSettings const clamped = Math.max(0, Math.min(p, pages.length - 1)); setCurrentPage(clamped); lastFlipPageRef.current = clamped; + // اولین اسپرد قبل از onChangeState('read') هم باید انیمیشن ورود بگیرد + scheduleEntranceForSpread(clamped); }, - [pages.length], + [pages.length, scheduleEntranceForSpread], ); /** بعد از اتمام انیمیشن ورق، ایندکس واقعی کتاب را می‌گیریم و انیمیشن ورود را یک‌بار شروع می‌کنیم */