Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
serhii-hrushun-empeek opened this issue Dec 10, 2020 · 11 comments · May be fixed by #2029
Open

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

serhii-hrushun-empeek opened this issue Dec 10, 2020 · 11 comments · May be fixed by #2029

Comments

@serhii-hrushun-empeek
Copy link

serhii-hrushun-empeek commented Dec 10, 2020

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:

  • react-slick: 0.27.13
  • react: 17.0.1

Is any recipes how to solve it?
Similar issue: #1874

@VadimSvirdoff
Copy link

Created bug fix pull request. #1950

@VadimSvirdoff
Copy link

VadimSvirdoff commented Jan 19, 2021

@akiran #1950 ready to merge

@Elecweb
Copy link

Elecweb commented Jan 28, 2021

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
Copy link

Any update about this?

@Goldziher
Copy link

Is this library maintained?

@AlexandrKolesnikov
Copy link

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

Thank you in advance!

@nawazassad
Copy link

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
Copy link

hey guys! any chance to fix it? thank you

@rhythmshandlya
Copy link

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

@HQDung
Copy link

HQDung commented Aug 2, 2022

got the same issue, any update on this?

@MaksymRudnyiIDIQ
Copy link

The issue is still not resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.