Skip to content

Commit

Permalink
fix: fix carousel scrolling bug when trigger click
Browse files Browse the repository at this point in the history
  • Loading branch information
wonuanyangying committed Aug 5, 2024
1 parent f4292cf commit 8b62ee3
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/arcodesign/components/carousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,11 @@ const Carousel = forwardRef((props: CarouselProps, ref: Ref<CarouselRef>) => {
if (posAdjustingRef.current) {
return;
}
// touchMove触发时,阻止handleTouchStart多次执行(如点击事件)
// @en When touchMove is triggered, prevent handleTouchStart from executing multiple times (such as click events)
if (touchStartedRef.current && touchMovedRef.current) {
return;
}
touchStartedRef.current = true;
touchMovedRef.current = false;
clear();
Expand Down Expand Up @@ -1034,16 +1039,18 @@ const Carousel = forwardRef((props: CarouselProps, ref: Ref<CarouselRef>) => {
jumpTo(index, false);
return;
}
if (
!touchStartedRef.current ||
!touchMovedRef.current ||
posAdjustingRef.current ||
touchStoppedRef.current
) {
if (!touchStartedRef.current) {
return;
}
touchStartedRef.current = false;
if (!touchMovedRef.current) {
setPlayIntervalRef.current();
return;
}
touchMovedRef.current = false;
if (posAdjustingRef.current || touchStoppedRef.current) {
return;
}
const touchEndTime = new Date().getTime();
const dis = Math.abs(distance);
const speed = (dis / (touchEndTime - touchStartTimeRef.current)) * 1000;
Expand Down

0 comments on commit 8b62ee3

Please sign in to comment.