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

fix: swiper item width when there is less than x items #2535

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/Swiper/src/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export const Container = styled.ul<Pick<UseSwiper, 'slidesPerView' | 'spaceBetwe
list-style-type: none;
margin-right: ${spaceBetween};
min-width: ${getSlideWidth(mobile, spaceBetween, theme.toRem)};
max-width: ${getSlideWidth(mobile, spaceBetween, theme.toRem)};
Comment on lines 117 to +118
Copy link
Contributor

@theo-mesnil theo-mesnil Sep 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum du coup possiblement un width ferait l'affaire ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, css est un peu chelou sur ce point. Ça fonctionne uniquement en utilisant max/min width 🤷🏼‍♀️

flex: 1;

&:last-child {
Expand All @@ -127,6 +128,7 @@ export const Container = styled.ul<Pick<UseSwiper, 'slidesPerView' | 'spaceBetwe
css`
> * {
min-width: ${getSlideWidth(mobile, spaceBetween, theme.toRem)};
max-width: ${getSlideWidth(mobile, spaceBetween, theme.toRem)};

&:nth-of-type(${mobile}n + 1) {
scroll-snap-align: start;
Expand All @@ -140,6 +142,7 @@ export const Container = styled.ul<Pick<UseSwiper, 'slidesPerView' | 'spaceBetwe
css`
> * {
min-width: ${getSlideWidth(tablet, spaceBetween, theme.toRem)};
max-width: ${getSlideWidth(tablet, spaceBetween, theme.toRem)};

&:nth-of-type(${tablet}n + 1) {
scroll-snap-align: start;
Expand All @@ -153,6 +156,7 @@ export const Container = styled.ul<Pick<UseSwiper, 'slidesPerView' | 'spaceBetwe
css`
> * {
min-width: ${getSlideWidth(desktop, spaceBetween, theme.toRem)};
max-width: ${getSlideWidth(desktop, spaceBetween, theme.toRem)};
scroll-snap-align: unset;

&:nth-of-type(${desktop}n + 1) {
Expand All @@ -172,6 +176,7 @@ export const Container = styled.ul<Pick<UseSwiper, 'slidesPerView' | 'spaceBetwe
css`
> * {
min-width: ${getSlideWidth(desktop + 2, spaceBetween, theme.toRem)};
max-width: ${getSlideWidth(desktop + 2, spaceBetween, theme.toRem)};
}
`}
}
Expand Down
Loading