Skip to content

Commit

Permalink
Merge pull request #1857 from akiran/swipe-right-issue
Browse files Browse the repository at this point in the history
fix an issue with slick-current when swiped from left to right on fir…
  • Loading branch information
akiran authored Aug 5, 2020
2 parents 2b44d88 + bef98be commit d17c1f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-slick",
"version": "0.27.2",
"version": "0.27.3",
"description": " React port of slick carousel",
"main": "./lib",
"files": [
Expand Down
11 changes: 8 additions & 3 deletions src/utils/innerSliderUtils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import React from "react";

export function clamp(number, lowerBound, upperBound) {
return Math.max(lowerBound, Math.min(number, upperBound));
}

export const getOnDemandLazySlides = spec => {
let onDemandSlides = [];
let startIndex = lazyStartIndex(spec);
Expand Down Expand Up @@ -172,6 +176,7 @@ export const slideHandler = spec => {
finalLeft;
let state = {},
nextState = {};
const targetSlide = infinite ? index : clamp(index, 0, slideCount);
if (fade) {
if (!infinite && (index < 0 || index >= slideCount)) return {};
if (index < 0) {
Expand Down Expand Up @@ -220,22 +225,22 @@ export const slideHandler = spec => {
currentSlide: finalSlide,
trackStyle: getTrackCSS({ ...spec, left: finalLeft }),
lazyLoadedList,
targetSlide: index
targetSlide
};
} else {
state = {
animating: true,
currentSlide: finalSlide,
trackStyle: getTrackAnimateCSS({ ...spec, left: animationLeft }),
lazyLoadedList,
targetSlide: index
targetSlide
};
nextState = {
animating: false,
currentSlide: finalSlide,
trackStyle: getTrackCSS({ ...spec, left: finalLeft }),
swipeLeft: null,
targetSlide: index
targetSlide
};
}
}
Expand Down

0 comments on commit d17c1f1

Please sign in to comment.