Skip to content

Commit

Permalink
(fix) can go next if in center mode akiran#1232
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladka Janu committed May 29, 2019
1 parent f6a2853 commit 7b62380
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/dots.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const getDotCount = spec => {

if (spec.infinite) {
dots = Math.ceil(spec.slideCount / spec.slidesToScroll);
} else if (slidesToScroll > 1) {
dots = Math.ceil((slideCount - slidesToShow) / slidesToScroll) + 1;
} else {
dots =
Math.ceil((spec.slideCount - spec.slidesToShow) / spec.slidesToScroll) +
1;
dots = Math.ceil(slideCount);
}

return dots;
Expand Down
14 changes: 8 additions & 6 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 @@ -79,8 +79,9 @@ export const canGoNext = spec => {
if (spec.centerMode && spec.currentSlide >= spec.slideCount - 1) {
canGo = false;
} else if (
spec.slideCount <= spec.slidesToShow ||
spec.currentSlide >= spec.slideCount - spec.slidesToShow
!spec.centerMode &&
(spec.slideCount <= spec.slidesToShow ||
spec.currentSlide >= spec.slideCount - spec.slidesToShow)
) {
canGo = false;
}
Expand Down Expand Up @@ -195,7 +196,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 +266,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 @@ -704,7 +706,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 7b62380

Please sign in to comment.