akiran / react-slick

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

Changing slide works incorrect when infinite is false and initialSlide > 1 #1946

Open serhii-hrushun-empeek opened 3 years ago

serhii-hrushun-empeek commented 3 years ago

Changing slide when initialSlide > 1 and infinite is false works wrong. When I swipe right I expect to see next slide(initial + 1), but I always see second slide as next, when I swipe left, I always get first slide. Also same behaviour when I click on arrows on this example, but with initialSlide: 2, infinite: false. I think that same behaviour we have always when initial slide is set and infinite setting is false.

Link to stackblitz to reproduce. https://stackblitz.com/edit/react-brc9ys?file=src%2FApp.js Versions:

Is any recipes how to solve it? Similar issue: https://github.com/akiran/react-slick/issues/1874

VadimSvirdoff commented 3 years ago

Created bug fix pull request. https://github.com/akiran/react-slick/pull/1950

VadimSvirdoff commented 3 years ago

@akiran #1950 ready to merge

Elecweb commented 3 years ago

Anyone who can't wait this issue fixed, you can use this as workaround

  const [hasSetPosition, setHasSetPosition] = useState(false);

  useEffect(() => {
    if (slider.current && !hasSetPosition) {
      slider.current?.slickGoTo(initialSlidePosition);
      setHasSetPosition(true);
    }
  }, [initialSlidePosition, hasSetPosition, slider]);

Swipe or slick's methods for navigate will work correctly.

felipe-gustavo commented 3 years ago

Any update about this?

Goldziher commented 3 years ago

Is this library maintained?

AlexandrKolesnikov commented 2 years ago

Hi @akiran, could you please tell whether there're any updates? Really excited to have this fix provided.

Thank you in advance!

nawazassad commented 2 years ago

This issue is still not resolved. When initial state is set to last index and infinite mode is false Issue: When you click on the previous button instead of going to index 1 it scrolls down to 0.

tanyaburlakova commented 2 years ago

hey guys! any chance to fix it? thank you

rhythmshandlya commented 2 years ago

Any updates guys, any quick fix? Really need this urgently!

HQDung commented 2 years ago

got the same issue, any update on this?

MaksymRudnyiIDIQ commented 2 years ago

The issue is still not resolved.