Skip to content

Commit

Permalink
fix(core): reset slides size when slidesPerView switches to auto
Browse files Browse the repository at this point in the history
fixes #4881
  • Loading branch information
nolimits4web committed Aug 30, 2021
1 parent 2e6560b commit 2c8784b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/core/update/updateSlides.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ export default function updateSlides() {
// Calc slides
let slideSize;

const shouldResetSlideSize =
params.slidesPerView === 'auto' &&
params.breakpoints &&
Object.keys(params.breakpoints).filter((key) => {
return typeof params.breakpoints[key].slidesPerView !== 'undefined';
}).length > 0;

for (let i = 0; i < slidesLength; i += 1) {
slideSize = 0;
const slide = slides.eq(i);
Expand All @@ -86,6 +93,9 @@ export default function updateSlides() {
if (slide.css('display') === 'none') continue; // eslint-disable-line

if (params.slidesPerView === 'auto') {
if (shouldResetSlideSize) {
slides[i].style[getDirectionLabel('width')] = ``;

This comment has been minimized.

Copy link
@manuelmeister

manuelmeister Nov 7, 2021

@nolimits4web This does not work if the size is inline set.

<div class="swiper-slide" style="width:300px;height:500px">

}
const slideStyles = getComputedStyle(slide[0]);
const currentTransform = slide[0].style.transform;
const currentWebKitTransform = slide[0].style.webkitTransform;
Expand Down

0 comments on commit 2c8784b

Please sign in to comment.