From 4a38cad0a40100321b00e65b6bc815b1dc13e973 Mon Sep 17 00:00:00 2001 From: monoid Date: Sun, 7 Apr 2024 22:35:59 +0900 Subject: [PATCH] fix sustain opacity --- packages/client/src/page/reader/comicPage.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/client/src/page/reader/comicPage.tsx b/packages/client/src/page/reader/comicPage.tsx index 5ae10ef..83fc38b 100644 --- a/packages/client/src/page/reader/comicPage.tsx +++ b/packages/client/src/page/reader/comicPage.tsx @@ -39,10 +39,14 @@ function ComicViewer({ useEffect(() => { if(currentImageRef.current){ + if (curPage < 0 || curPage >= totalPage) { + return; + } const img = new Image(); img.src = `/api/doc/${doc.id}/comic/${curPage}`; if (img.complete) { currentImageRef.current.src = img.src; + setFade(false); return; } setFade(true); @@ -60,7 +64,7 @@ function ComicViewer({ // TODO: use web worker to abort loading image in the future }; } - }, [curPage, doc.id]); + }, [curPage, doc.id, totalPage]); return (