fix: carousel touch warning, close #5040

pull/5043/head
tangjinzhou 2021-12-15 23:52:43 +08:00
parent 9791231e63
commit af2e2683b4
1 changed files with 9 additions and 4 deletions

View File

@ -1,3 +1,5 @@
import supportsPassive from '../../../_util/supportsPassive';
export const getOnDemandLazySlides = spec => { export const getOnDemandLazySlides = spec => {
const onDemandSlides = []; const onDemandSlides = [];
const startIndex = lazyStartIndex(spec); const startIndex = lazyStartIndex(spec);
@ -275,7 +277,7 @@ export const keyHandler = (e, accessibility, rtl) => {
}; };
export const swipeStart = (e, swipe, draggable) => { 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 ''; if (!swipe || (!draggable && e.type.indexOf('mouse') !== -1)) return '';
return { return {
dragging: true, dragging: true,
@ -311,8 +313,11 @@ export const swipeMove = (e, spec) => {
listWidth, listWidth,
} = spec; } = spec;
if (scrolling) return; if (scrolling) return;
if (animating) return e.preventDefault(); if (animating) {
if (vertical && swipeToSlide && verticalSwiping) e.preventDefault(); !supportsPassive && e.preventDefault();
return;
}
if (vertical && swipeToSlide && verticalSwiping) !supportsPassive && e.preventDefault();
let swipeLeft; let swipeLeft;
let state = {}; let state = {};
const curLeft = getTrackLeft(spec); const curLeft = getTrackLeft(spec);
@ -379,7 +384,7 @@ export const swipeMove = (e, spec) => {
} }
if (touchObject.swipeLength > 10) { if (touchObject.swipeLength > 10) {
state['swiping'] = true; state['swiping'] = true;
e.preventDefault(); !supportsPassive && e.preventDefault();
} }
return state; return state;
}; };