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

Controller controling multiple swipers - wrong calculation #6506

Closed
6 tasks done
mroz123 opened this issue Mar 19, 2023 · 1 comment
Closed
6 tasks done

Controller controling multiple swipers - wrong calculation #6506

mroz123 opened this issue Mar 19, 2023 · 1 comment

Comments

@mroz123
Copy link

mroz123 commented Mar 19, 2023

Check that this is really a bug

  • I confirm

Reproduction link

https://codesandbox.io/p/sandbox/swiper-multiple-swipers-forked-dcg4xm?file=%2Findex.html&selection=%5B%7B%22endColumn%22%3A29%2C%22endLineNumber%22%3A65%2C%22startColumn%22%3A29%2C%22startLineNumber%22%3A65%7D%5D

Bug description

When one swiper with controller module controls multiple swipers with different widths it calculates their progress wrong.

I believe the problem is in

if (!swiper.controller.spline) {

which saves the interpolation values based on the dimensions of the first controlled swiper which can't be used for another one with different dimensions because it messes up the progress calculation.

I believe it should be enough to remove the condition on line 62 which would allow the swiper.controller.spline to regenerate for every controlled swiper and allow for correct progress calculation.

It is not really very clear from comment in the code why this condition was added so I am not sure if it won't break anything else.

Expected Behavior

When the progress of the swiper with controller is 0.5, the progress of every controlled swiper should also be 0.5.

Actual Behavior

When the progress of the controlling swiper is 0.5 , the progress of the first controlled swiper is correct but the progress of other swipers is based on the size of the first one so the progress values are wrong which causes them to move with wrong speed.

Swiper version

9.1.0

Platform/Target and Browser Versions

any

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
@nolimits4web
Copy link
Owner

Thank you for the tip! Fixed now

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

No branches or pull requests

2 participants