From 739c864f0e51520a4a752cc4fbc32a30860aa3c9 Mon Sep 17 00:00:00 2001 From: Anderson Souza Date: Fri, 28 Jan 2022 09:16:31 -0300 Subject: [PATCH] Fix Bug on vertical scroll clicking over carousel --- src/components/Carousel.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Carousel.tsx b/src/components/Carousel.tsx index 4c1573d..bc1bed2 100644 --- a/src/components/Carousel.tsx +++ b/src/components/Carousel.tsx @@ -439,8 +439,12 @@ const CarouselItem = ({ animation, next, prev, swipe, state, index, maxIndex, du drag: 'x', layout: true, onDragEnd: (event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo): void => { - if (!swipe) return; + const pX = info.offset.x * info.offset.x; + const pY = info.offset.y * info.offset.y; + + if (!swipe || pX < 300 || pX < pY) return; console.log(info); + if (info.offset.x > 0) prev && prev(); else if (info.offset.x < 0) next && next();