Rework #6

Merged
monoid merged 38 commits from dev into main 2024-04-17 01:45:37 +09:00
Showing only changes of commit 4a38cad0a4 - Show all commits

View File

@ -39,10 +39,14 @@ function ComicViewer({
useEffect(() => { useEffect(() => {
if(currentImageRef.current){ if(currentImageRef.current){
if (curPage < 0 || curPage >= totalPage) {
return;
}
const img = new Image(); const img = new Image();
img.src = `/api/doc/${doc.id}/comic/${curPage}`; img.src = `/api/doc/${doc.id}/comic/${curPage}`;
if (img.complete) { if (img.complete) {
currentImageRef.current.src = img.src; currentImageRef.current.src = img.src;
setFade(false);
return; return;
} }
setFade(true); setFade(true);
@ -60,7 +64,7 @@ function ComicViewer({
// TODO: use web worker to abort loading image in the future // TODO: use web worker to abort loading image in the future
}; };
} }
}, [curPage, doc.id]); }, [curPage, doc.id, totalPage]);
return ( return (
<div className="overflow-hidden w-full h-full relative"> <div className="overflow-hidden w-full h-full relative">