diff --git a/components/PublicGrid.tsx b/components/PublicGrid.tsx index dc975b6..ec73500 100644 --- a/components/PublicGrid.tsx +++ b/components/PublicGrid.tsx @@ -448,7 +448,7 @@ function FlipBook({ pages, onClose }: { pages: string[]; onClose: () => void }) const [spread, setSpread] = useState(0); const [flipping, setFlipping] = useState<'forward' | 'backward' | null>(null); const audioRef = useRef(null); - const touchStartX = useRef(null); + const dragStartX = useRef(null); const getCtx = () => { if (!audioRef.current) { @@ -493,13 +493,14 @@ function FlipBook({ pages, onClose }: { pages: string[]; onClose: () => void }) return () => window.removeEventListener('keydown', onKey); }, [onClose, goNext, goPrev]); - const onTouchStart = (e: React.TouchEvent) => { touchStartX.current = e.touches[0].clientX; }; - const onTouchEnd = (e: React.TouchEvent) => { - if (touchStartX.current === null) return; - const dx = e.changedTouches[0].clientX - touchStartX.current; + const onPointerDown = (e: React.PointerEvent) => { dragStartX.current = e.clientX; }; + const onPointerUp = (e: React.PointerEvent) => { + if (dragStartX.current === null) return; + const dx = e.clientX - dragStartX.current; if (Math.abs(dx) > 50) (dx < 0 ? goNext() : goPrev()); - touchStartX.current = null; + dragStartX.current = null; }; + const onPointerCancel = () => { dragStartX.current = null; }; // Pages visible underneath the flipping overlay const visibleLeft = flipping === 'backward' ? getPage(prevLeftIdx) : getPage(leftIdx); @@ -516,10 +517,11 @@ function FlipBook({ pages, onClose }: { pages: string[]; onClose: () => void }) return (