diff --git a/src/components/reader/components/PageDisplay.tsx b/src/components/reader/components/PageDisplay.tsx
index d69539b..844dda6 100644
--- a/src/components/reader/components/PageDisplay.tsx
+++ b/src/components/reader/components/PageDisplay.tsx
@@ -20,21 +20,35 @@ export function PageDisplay({
getPageUrl,
}: PageDisplayProps) {
const [isLoading, setIsLoading] = useState(true);
+ const [hasError, setHasError] = useState(false);
const [secondPageLoading, setSecondPageLoading] = useState(true);
+ const [secondPageHasError, setSecondPageHasError] = useState(false);
const { isRTL } = useReadingDirection();
const handleImageLoad = useCallback(() => {
setIsLoading(false);
}, []);
+ const handleImageError = useCallback(() => {
+ setIsLoading(false);
+ setHasError(true);
+ }, []);
+
const handleSecondImageLoad = useCallback(() => {
setSecondPageLoading(false);
}, []);
+ const handleSecondImageError = useCallback(() => {
+ setSecondPageLoading(false);
+ setSecondPageHasError(true);
+ }, []);
+
// Reset loading when page changes
useEffect(() => {
setIsLoading(true);
+ setHasError(false);
setSecondPageLoading(true);
+ setSecondPageHasError(false);
}, [currentPage, isDoublePage]);
return (
@@ -47,8 +61,8 @@ export function PageDisplay({
isDoublePage && shouldShowDoublePage(currentPage) ? "w-1/2" : "w-full justify-center",
isDoublePage &&
shouldShowDoublePage(currentPage) && {
- "order-2 justify-start": isRTL,
- "order-1 justify-end": !isRTL,
+ "order-2 justify-center": isRTL,
+ "order-1 justify-center": !isRTL,
}
)}
>
@@ -63,33 +77,46 @@ export function PageDisplay({
)}
- {/* eslint-disable-next-line @next/next/no-img-element */}
- {
- // Si l'image est déjà en cache, onLoad ne sera pas appelé
- if (img?.complete && img?.naturalHeight !== 0) {
- handleImageLoad();
- }
- }}
- />
+ {hasError ? (
+