This commit is contained in:
Hamid
2026-05-16 23:40:23 -07:00
parent fef8099ab1
commit 731353a4a8
+8 -2
View File
@@ -199,7 +199,11 @@ const BookViewer: FC<BookViewerProps> = ({ pages, catalogSize, documentSettings
useEffect(() => { useEffect(() => {
resetEntrance(); resetEntrance();
}, [flipKey, pages.length, pages[0]?.id, resetEntrance]); const frame = requestAnimationFrame(() => {
commitEntranceAtCurrentSpread();
});
return () => cancelAnimationFrame(frame);
}, [flipKey, pages.length, pages[0]?.id, resetEntrance, commitEntranceAtCurrentSpread]);
// اطمینان از اینکه currentPage همیشه در محدوده معتبر است // اطمینان از اینکه currentPage همیشه در محدوده معتبر است
useEffect(() => { useEffect(() => {
@@ -306,8 +310,10 @@ const BookViewer: FC<BookViewerProps> = ({ pages, catalogSize, documentSettings
const clamped = Math.max(0, Math.min(p, pages.length - 1)); const clamped = Math.max(0, Math.min(p, pages.length - 1));
setCurrentPage(clamped); setCurrentPage(clamped);
lastFlipPageRef.current = clamped; lastFlipPageRef.current = clamped;
// اولین اسپرد قبل از onChangeState('read') هم باید انیمیشن ورود بگیرد
scheduleEntranceForSpread(clamped);
}, },
[pages.length], [pages.length, scheduleEntranceForSpread],
); );
/** بعد از اتمام انیمیشن ورق، ایندکس واقعی کتاب را می‌گیریم و انیمیشن ورود را یک‌بار شروع می‌کنیم */ /** بعد از اتمام انیمیشن ورق، ایندکس واقعی کتاب را می‌گیریم و انیمیشن ورود را یک‌بار شروع می‌کنیم */