Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix-1650 #1971

Merged
merged 4 commits into from
Jan 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/utils/innerSliderUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ export function clamp(number, lowerBound, upperBound) {
return Math.max(lowerBound, Math.min(number, upperBound));
}

export const safePreventDefault = event => {
const passiveEvents = ["onTouchStart", "onTouchMove", "onWheel"];
if(!passiveEvents.includes(event._reactName)) {
event.preventDefault();
}
}

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

export const swipeStart = (e, swipe, draggable) => {
e.target.tagName === "IMG" && e.preventDefault();
e.target.tagName === "IMG" && safePreventDefault(e);
if (!swipe || (!draggable && e.type.indexOf("mouse") !== -1)) return "";
return {
dragging: true,
Expand Down Expand Up @@ -352,8 +359,8 @@ export const swipeMove = (e, spec) => {
listWidth
} = spec;
if (scrolling) return;
if (animating) return e.preventDefault();
if (vertical && swipeToSlide && verticalSwiping) e.preventDefault();
if (animating) return safePreventDefault(e);
if (vertical && swipeToSlide && verticalSwiping) safePreventDefault(e);
let swipeLeft,
state = {};
let curLeft = getTrackLeft(spec);
Expand Down Expand Up @@ -421,7 +428,7 @@ export const swipeMove = (e, spec) => {
}
if (touchObject.swipeLength > 10) {
state["swiping"] = true;
e.preventDefault();
safePreventDefault(e);
}
return state;
};
Expand All @@ -442,7 +449,7 @@ export const swipeEnd = (e, spec) => {
infinite
} = spec;
if (!dragging) {
if (swipe) e.preventDefault();
if (swipe) safePreventDefault(e);
return {};
}
let minSwipe = verticalSwiping
Expand All @@ -466,7 +473,7 @@ export const swipeEnd = (e, spec) => {
return state;
}
if (touchObject.swipeLength > minSwipe) {
e.preventDefault();
safePreventDefault(e);
if (onSwipe) {
onSwipe(swipeDirection);
}
Expand Down