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

Fix type Number in slideToLoop.js #5732

Merged
merged 2 commits into from
May 31, 2022

Conversation

vchereshnevyi
Copy link
Contributor

@vchereshnevyi vchereshnevyi commented May 19, 2022

You should check slideToLoop function for Number type as you did in slideTo, because in case with custom pagination, developer may use own structure with data attributes and pass those arguments to slideToLoop.

In my case I have broken pagination because slideToLoop function returned '35' with Math '3' + swiper.loopedSlides // 5

const index = Number(event.target.dataset.slideto); // '3'

if (this.options.loop) {
    this.slider.slideToLoop(index); //  => '35'
} else {
    this.slider.slideTo(index); // => 3
}

You should check here for Number type as you do in slideTo, because in case with custom pagination, developer may use own structure with data attributes, and pass this argument to slideToLoop. 
In my case I have broken pagination because this condition works only for no loop mode:
const index = Number(event.target.dataset.slideto); // '3'
if (this.options.loop) {
    this.slider.slideToLoop(index); // '3'
} else {
    this.slider.slideTo(index); // '3'
}
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

Successfully merging this pull request may close these issues.

2 participants