Skip to content

Commit e45b9e7

Browse files
committedAug 16, 2020
Fix an issue with prev button clicks in fade mode
1 parent d19bc96 commit e45b9e7

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed
 

‎docs/single-demo.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
import React from "react";
44
import ReactDOM from "react-dom";
55
import Slider from "../src/slider";
6-
import UnevenSetsFinite from "../examples/UnevenSetsFinite";
7-
import UnevenSetsInfinite from "../examples/UnevenSetsInfinite";
8-
96
function SimpleSlider() {
107
const settings = {
118
dots: true,
@@ -44,8 +41,7 @@ function SimpleSlider() {
4441
function App() {
4542
return (
4643
<div className="content">
47-
<UnevenSetsFinite />
48-
{/* <UnevenSetsInfinite /> */}
44+
<SimpleSlider />
4945
</div>
5046
);
5147
}

‎examples/Fade.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export default class Fade extends Component {
1010
infinite: true,
1111
speed: 500,
1212
slidesToShow: 1,
13-
slidesToScroll: 1
13+
slidesToScroll: 1,
14+
waitForAnimate: false
1415
};
1516
return (
1617
<div>

‎examples/__tests__/Fade.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from "react";
2+
import { mount } from "enzyme";
3+
import Fade from "../Fade";
4+
import { clickNext, clickPrev } from "../../__tests__/testUtils";
5+
6+
describe("Fade", () => {
7+
it("should change slides when clicked on next & prev buttons", () => {
8+
const slider = mount(<Fade />);
9+
let activeSlide = slider.find("div.slick-active");
10+
expect(activeSlide.props()["data-index"]).toEqual(0);
11+
clickNext(slider);
12+
activeSlide = slider.find("div.slick-active");
13+
expect(activeSlide.props()["data-index"]).toEqual(1);
14+
clickPrev(slider);
15+
activeSlide = slider.find("div.slick-active");
16+
expect(activeSlide.props()["data-index"]).toEqual(0);
17+
});
18+
});

‎examples/__tests__/__snapshots__/MultipleItems.test.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ exports[`Multiple Items should show slides first 3 slides when middle dot is cli
989989
<h2> Multiple items </h2>
990990
<div class=\\"slick-slider slick-initialized\\" dir=\\"ltr\\"><button type=\\"button\\" data-role=\\"none\\" class=\\"slick-arrow slick-prev\\" style=\\"display: block;\\"> Previous</button>
991991
<div class=\\"slick-list\\">
992-
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px);\\">
992+
<div class=\\"slick-track\\" style=\\"opacity: 1; transform: translate3d(0px, 0px, 0px); transition: transform 500ms ease;\\">
993993
<div data-index=\\"-3\\" tabindex=\\"-1\\" class=\\"slick-slide slick-cloned\\" aria-hidden=\\"true\\" style=\\"width: 0px;\\">
994994
<div>
995995
<div tabindex=\\"-1\\" style=\\"width: 100%; display: inline-block;\\">

‎src/inner-slider.js

-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ export class InnerSlider extends React.Component {
410410
changeSlide = (options, dontAnimate = false) => {
411411
const spec = { ...this.props, ...this.state };
412412
let targetSlide = changeSlide(spec, options);
413-
if (targetSlide === this.state.targetSlide) return;
414413
if (targetSlide !== 0 && !targetSlide) return;
415414
if (dontAnimate === true) {
416415
this.slideHandler(targetSlide, dontAnimate);

0 commit comments

Comments
 (0)
Please sign in to comment.