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

Breakpoints don't work with slidesPerColumn and spaceBetween correctly after resize window #4044

Closed
1 of 3 tasks
alvteren opened this issue Dec 12, 2020 · 1 comment
Closed
1 of 3 tasks

Comments

@alvteren
Copy link

This is a (multiple allowed):

I wrote this config:

var swiper = new Swiper('.swiper-container', {
      slidesPerView: 3,
      slidesPerColumn: 2,
      spaceBetween: 30,
      loop: true,
      pagination: {
        el: '.swiper-pagination',
        clickable: true,
      },
      breakpoints: {
        400: {
          slidesPerColumn: 1,
        }
      }
    });

and after resize window I see wrong margins

Before resize:
image

After resize to >400px:
image

@mmanista
Copy link

As a workaround, you can potentially listen for window resize events, and, when bypassing the breakpoint defined in Swiper (400px in your case), remove the margin-top from the shifted slides. Not ideal, but should work.

Here's the demo I've created that doesn't use the loop mode (that needs some extra configuration when slidesPerView is used: https://stackblitz.com/edit/swiper-demo-17-multi-row-slides-layout-r1qmq6

In the example above, you would need to reset the margin-top of 4th slide or 5th slide, depending on the current viewport width.

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

3 participants