diff --git a/src/components/reader/BookReader.tsx b/src/components/reader/BookReader.tsx index f3dd49f..4da0963 100644 --- a/src/components/reader/BookReader.tsx +++ b/src/components/reader/BookReader.tsx @@ -281,9 +281,44 @@ export function BookReader({ book, pages, onClose }: BookReaderProps) { }; }, []); + const [touchStart, setTouchStart] = useState(null); + const [touchEnd, setTouchEnd] = useState(null); + + // Seuil minimum de déplacement pour déclencher un swipe + const minSwipeDistance = 50; + + const onTouchStart = (e: React.TouchEvent) => { + setTouchEnd(null); + setTouchStart(e.targetTouches[0].clientX); + }; + + const onTouchMove = (e: React.TouchEvent) => { + setTouchEnd(e.targetTouches[0].clientX); + }; + + const onTouchEnd = () => { + if (!touchStart || !touchEnd) return; + + const distance = touchStart - touchEnd; + const isLeftSwipe = distance > minSwipeDistance; + const isRightSwipe = distance < -minSwipeDistance; + + if (isLeftSwipe && currentPage < pages.length) { + handleNextPage(); + } + if (isRightSwipe && currentPage > 1) { + handlePreviousPage(); + } + }; + return (
-
+
{/* Contenu principal */}
{/* Boutons en haut */}