swiper icon indicating copy to clipboard operation
swiper copied to clipboard

Updating `slidesPerView` and `breakpoints.*.slidesPerView` does not correctly refresh the slider

Open Prinzhorn opened this issue 1 year ago • 8 comments

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

Prinzhorn avatar Jul 01 '24 08:07 Prinzhorn

Same here!

samuel-clara avatar Jul 04 '24 11:07 samuel-clara

Same here Swiper doesn't update when slidesPerView changes

ArianHamdi avatar Jul 25 '24 23:07 ArianHamdi

Same here

adrian-nita avatar Sep 13 '24 06:09 adrian-nita

here's solution https://github.com/nolimits4web/swiper/issues/3539#issuecomment-995815717

ole-an avatar Sep 25 '24 16:09 ole-an

The solution from #3539 didn't work for me. Is there a fix for this so that we can update the breakpoints?

kilobyte2007 avatar Dec 05 '24 15:12 kilobyte2007

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

ayo-odoo avatar Feb 10 '25 08:02 ayo-odoo

Same here

rigobauer avatar Apr 25 '25 15:04 rigobauer

Same problem here ☹️, the solution from #3539 didn't work for me

RubenZx avatar Apr 25 '25 15:04 RubenZx

same, the fix is working though, you just have to make a zeroth breakpoint

hadamlenz avatar Aug 11 '25 18:08 hadamlenz