swiper
swiper copied to clipboard
Updating `slidesPerView` and `breakpoints.*.slidesPerView` does not correctly refresh the slider
Check that this is really a bug
- [X] I confirm
Reproduction link
https://codesandbox.io/p/sandbox/swiper-slides-per-view-forked-cl2tdw?file=%2Findex.html%3A30%2C8
Bug description
When updating slidesPerView and breakpoints.*.slidesPerView the slider will be in an inconsistent state and only "fixes" itself by resizing the viewport to the breakpoint and back.
Screencast from 2024-07-01 10-15-30.webm
Expected Behavior
No response
Actual Behavior
No response
Swiper version
swiper@11
Platform/Target and Browser Versions
Ubuntu 23.10 with both Firefox 127.0.2 and Chromium 126.0.6478.114
Validations
- [X] Follow our Code of Conduct
- [X] Read the docs.
- [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
- [X] 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
Same here!
Same here
Swiper doesn't update when slidesPerView changes
Same here
here's solution https://github.com/nolimits4web/swiper/issues/3539#issuecomment-995815717
The solution from #3539 didn't work for me. Is there a fix for this so that we can update the breakpoints?
The solution from #3539 didn't work for me. Is there a fix for this so that we can update the breakpoints?
I faced this very bug today. In my case, I had to always set swiper.breakpoints[0].slidesPerView to swiper.params.slidesPerView instead of 1
this.swiper.params.breakpoints[0].slidesPerView = this.swiper.params.slidesPerView;
this.swiper.currentBreakpoint = false;
this.swiper.update(true, null, 0);
Maybe your usecase is similar to mine
Same here
Same problem here ☹️, the solution from #3539 didn't work for me
same, the fix is working though, you just have to make a zeroth breakpoint