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

Swiper miscalculates center #6599

Closed
5 of 6 tasks
dnlmzw opened this issue Apr 18, 2023 · 0 comments · May be fixed by ashok9k/Amazon-FE#5
Closed
5 of 6 tasks

Swiper miscalculates center #6599

dnlmzw opened this issue Apr 18, 2023 · 0 comments · May be fixed by ashok9k/Amazon-FE#5
Labels

Comments

@dnlmzw
Copy link

dnlmzw commented Apr 18, 2023

Check that this is really a bug

  • I confirm

Reproduction link

https://codesandbox.io/p/sandbox/swiper-react-mousewheel-control-forked-kui36d?file=%2Fsrc%2FApp.jsx&selection=%5B%7B%22endColumn%22%3A1%2C%22endLineNumber%22%3A8%2C%22startColumn%22%3A1%2C%22startLineNumber%22%3A8%7D%5D

Bug description

When using centeredSlides, loop and slidesPerView={"auto"} simultaneously, the slider doesn't calculate the correct center of the slides. The pagination also jumps to the incorrect slide when clicked, and the mousewheel on MacOS jumps multiple slides during the same swipe.

I have read the documentation for loop, which doesn't state that loop doesn't work with auto. It states that:

Set to true to enable continuous loop mode

Because of nature of how the loop mode works (it will rearrange slides), total number of slides must be >= slidesPerView * 2

I have 9 slides in my slider, which should account for total number of slides being larger than slidesPerView * 2.

Expected Behavior

  • Slides should be centered
  • Pagination should go to correct slide
  • Mousewheel shouldn't jump two slides in a row

Actual Behavior

  • Slides position after changing slides is unpredictable
  • Pagination doesn't go to the right slide
  • Mousewheel jumps multiple slides on same swipe

Swiper version

9.2.3

Platform/Target and Browser Versions

macOS Ventura 13.2.1 / Chrome 112.0.5615.49

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • Make sure this is a Swiper issue and not a framework-specific issue

Would you like to open a PR for this bug?

  • I'm willing to open a PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant