akiran / react-slick

React carousel component
http://react-slick.neostack.com/
MIT License
11.76k stars 2.11k forks source link

Wrong behaviour with initialSlide #2207

Closed egorovsa closed 1 year ago

egorovsa commented 1 year ago

1) infinite=false 2) set InitialSlide 3) swipe right

Expected result: it goes to the next slide Actual result: it always goes to slide 2

Reproduced there!

https://codesandbox.io/s/react-slick-playground-forked-8lnxbb?file=/index.js

gadanihiman commented 1 year ago

I got the same issue, anyone can fix it?

gadanihiman commented 1 year ago

have you got the solution? @egorovsa

egorovsa commented 1 year ago

Yes I found a solution, but this is.... how to say . Temp Monkey patching. But this works for me. Instead of using initialSlide prop I use ref and Slider API. Check this out

 // Since the slider's plugin has an initialSlider property setting issue
  // we set an initial slide using the package API
  // Issue is created https://github.com/akiran/react-slick/issues/2207
  const initSlider = (ref: Slider) => {
    ref?.slickGoTo(initialSlide || 0, true);
  };

//...

     <Slider
        ref={initSlider}
        dots={false}
        infinite={false}
      >
...
ashutosh887 commented 1 year ago

Let me have a look @akiran Please assign and please give an overview what needs to be fixed 😄

pratyushbh commented 1 year ago

this issue has been fixed.