Skip to content

Commit

Permalink
Merge pull request #280 from arco-design/fix-carousel-scrolling-bug
Browse files Browse the repository at this point in the history
fix: fix `carousel` scrolling bug when trigger click
  • Loading branch information
wonuanyangying authored Oct 21, 2024
2 parents 8a37b7c + 8b62ee3 commit 06a2153
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 06a2153

Please sign in to comment.