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

currentSlide number changes when perPage changes #151

Open
EricSSartorius opened this issue Mar 30, 2018 · 2 comments
Open

currentSlide number changes when perPage changes #151

EricSSartorius opened this issue Mar 30, 2018 · 2 comments

Comments

@EricSSartorius
Copy link

I have noticed that the currentSlide index isn't always the exact index of the image in the carousel when using different numbers for perPage.
For example, using perPage: {0: 1, 600: 3, 1240: 5}, works visually but I will randomly get negative and inconsistent numbers for currentSlide depending on if the perPage number is at 1, 3, or 5.

Example in codepen shown here: https://codepen.io/EricSSartorius/pen/BrrqOv

@pawelgrzybek
Copy link
Owner

Hi.

I see what is going on. It does lots of calculations to put a carousel in a correct location when you use loop: true. you are right that the index should be the one that user sees. I will try to change it in future versions.

Thanks for reporting Eric and have a cool day :)

@andrey-hohlov
Copy link

andrey-hohlov commented Jul 21, 2018

I solved this problem for correct dots navigation using this code:

// carousel = siema instance
let currentSlide = carousel.currentSlide;
if (currentSlide < 0) {
  currentSlide = carousel.innerElements.length + currentSlide;
}

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

No branches or pull requests

3 participants