Rework #6
@ -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">
|
||||||
|
Loading…
Reference in New Issue
Block a user