Skip to content

Commit

Permalink
fix: carousel touch warning, close #5040
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Dec 15, 2021
1 parent 9791231 commit af2e268
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions components/vc-slick/src/utils/innerSliderUtils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import supportsPassive from '../../../_util/supportsPassive';

export const getOnDemandLazySlides = spec => {
const onDemandSlides = [];
const startIndex = lazyStartIndex(spec);
Expand Down Expand Up @@ -275,7 +277,7 @@ export const keyHandler = (e, accessibility, rtl) => {
};

export const swipeStart = (e, swipe, draggable) => {
e.target.tagName === 'IMG' && e.preventDefault();
e.target.tagName === 'IMG' && !supportsPassive && e.preventDefault();
if (!swipe || (!draggable && e.type.indexOf('mouse') !== -1)) return '';
return {
dragging: true,
Expand Down Expand Up @@ -311,8 +313,11 @@ export const swipeMove = (e, spec) => {
listWidth,
} = spec;
if (scrolling) return;
if (animating) return e.preventDefault();
if (vertical && swipeToSlide && verticalSwiping) e.preventDefault();
if (animating) {
!supportsPassive && e.preventDefault();
return;
}
if (vertical && swipeToSlide && verticalSwiping) !supportsPassive && e.preventDefault();
let swipeLeft;
let state = {};
const curLeft = getTrackLeft(spec);
Expand Down Expand Up @@ -379,7 +384,7 @@ export const swipeMove = (e, spec) => {
}
if (touchObject.swipeLength > 10) {
state['swiping'] = true;
e.preventDefault();
!supportsPassive && e.preventDefault();
}
return state;
};
Expand Down

0 comments on commit af2e268

Please sign in to comment.