diff --git a/examples/with-cloudinary/components/SharedModal.tsx b/examples/with-cloudinary/components/SharedModal.tsx index 162e7e42e2274..5d738b114fc29 100644 --- a/examples/with-cloudinary/components/SharedModal.tsx +++ b/examples/with-cloudinary/components/SharedModal.tsx @@ -32,8 +32,16 @@ export default function SharedModal({ ) const handlers = useSwipeable({ - onSwipedLeft: () => changePhotoId(index + 1), - onSwipedRight: () => changePhotoId(index - 1), + onSwipedLeft: () => { + if (index < images?.length - 1) { + changePhotoId(index + 1) + } + }, + onSwipedRight: () => { + if (index > 0) { + changePhotoId(index - 1) + } + }, trackMouse: true, })