Skip to content

Commit

Permalink
Removed preventDefault on swipeStart and always call it on swipeMove
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDeFury committed Jul 31, 2018
1 parent 1a03228 commit fdd3f9e
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/utils/innerSliderUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const getSwipeDirection = (touchObject, verticalSwiping = false) => {
xDist = touchObject.startX - touchObject.curX;
yDist = touchObject.startY - touchObject.curY;
r = Math.atan2(yDist, xDist);
swipeAngle = Math.round(r * 180 / Math.PI);
swipeAngle = Math.round((r * 180) / Math.PI);
if (swipeAngle < 0) {
swipeAngle = 360 - Math.abs(swipeAngle);
}
Expand Down Expand Up @@ -195,7 +195,7 @@ export const slideHandler = spec => {
finalSlide = animationSlide + slideCount;
if (!infinite) finalSlide = 0;
else if (slideCount % slidesToScroll !== 0)
finalSlide = slideCount - slideCount % slidesToScroll;
finalSlide = slideCount - (slideCount % slidesToScroll);
} else if (!canGoNext(spec) && animationSlide > currentSlide) {
animationSlide = finalSlide = currentSlide;
} else if (centerMode && animationSlide >= slideCount) {
Expand Down Expand Up @@ -265,7 +265,8 @@ export const changeSlide = (spec, options) => {
slideOffset = indexOffset === 0 ? slidesToScroll : indexOffset;
targetSlide = currentSlide + slideOffset;
if (lazyLoad && !infinite) {
targetSlide = (currentSlide + slidesToScroll) % slideCount + indexOffset;
targetSlide =
((currentSlide + slidesToScroll) % slideCount) + indexOffset;
}
} else if (options.message === "dots") {
// Click on dots
Expand Down Expand Up @@ -304,7 +305,6 @@ export const keyHandler = (e, accessibility, rtl) => {
};

export const swipeStart = (e, swipe, draggable) => {
e.target.tagName === "IMG" && e.preventDefault();
if (!swipe || (!draggable && e.type.indexOf("mouse") !== -1)) return "";
return {
dragging: true,
Expand All @@ -322,7 +322,6 @@ export const swipeMove = (e, spec) => {
scrolling,
animating,
vertical,
swipeToSlide,
verticalSwiping,
rtl,
currentSlide,
Expand All @@ -339,9 +338,8 @@ export const swipeMove = (e, spec) => {
listHeight,
listWidth
} = spec;
if (scrolling) return;
if (animating) return e.preventDefault();
if (vertical && swipeToSlide && verticalSwiping) e.preventDefault();
e.preventDefault();
if (scrolling || animating) return;
let swipeLeft,
state = {};
let curLeft = getTrackLeft(spec);
Expand Down Expand Up @@ -409,7 +407,6 @@ export const swipeMove = (e, spec) => {
}
if (touchObject.swipeLength > 10) {
state["swiping"] = true;
e.preventDefault();
}
return state;
};
Expand Down Expand Up @@ -704,7 +701,7 @@ export const getTrackLeft = spec => {
slideCount % slidesToScroll !== 0 &&
slideIndex + slidesToScroll > slideCount
) {
slidesToOffset = slidesToShow - slideCount % slidesToScroll;
slidesToOffset = slidesToShow - (slideCount % slidesToScroll);
}
if (centerMode) {
slidesToOffset = parseInt(slidesToShow / 2);
Expand Down

0 comments on commit fdd3f9e

Please sign in to comment.