Skip to content

Commit af2e268

Browse files
committed
fix: carousel touch warning, close #5040
1 parent 9791231 commit af2e268

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

components/vc-slick/src/utils/innerSliderUtils.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import supportsPassive from '../../../_util/supportsPassive';
2+
13
export const getOnDemandLazySlides = spec => {
24
const onDemandSlides = [];
35
const startIndex = lazyStartIndex(spec);
@@ -275,7 +277,7 @@ export const keyHandler = (e, accessibility, rtl) => {
275277
};
276278

277279
export const swipeStart = (e, swipe, draggable) => {
278-
e.target.tagName === 'IMG' && e.preventDefault();
280+
e.target.tagName === 'IMG' && !supportsPassive && e.preventDefault();
279281
if (!swipe || (!draggable && e.type.indexOf('mouse') !== -1)) return '';
280282
return {
281283
dragging: true,
@@ -311,8 +313,11 @@ export const swipeMove = (e, spec) => {
311313
listWidth,
312314
} = spec;
313315
if (scrolling) return;
314-
if (animating) return e.preventDefault();
315-
if (vertical && swipeToSlide && verticalSwiping) e.preventDefault();
316+
if (animating) {
317+
!supportsPassive && e.preventDefault();
318+
return;
319+
}
320+
if (vertical && swipeToSlide && verticalSwiping) !supportsPassive && e.preventDefault();
316321
let swipeLeft;
317322
let state = {};
318323
const curLeft = getTrackLeft(spec);
@@ -379,7 +384,7 @@ export const swipeMove = (e, spec) => {
379384
}
380385
if (touchObject.swipeLength > 10) {
381386
state['swiping'] = true;
382-
e.preventDefault();
387+
!supportsPassive && e.preventDefault();
383388
}
384389
return state;
385390
};

0 commit comments

Comments
 (0)