Replies: 1 comment
|
@BluNub20 Yes, this layout is possible. I reproduced a similar disappearing-neighbor issue using your desktop settings with a container-width Swiper and The distinction is between the content container (two full cards) and the Swiper viewport (including both outside peeks). The approach that passed my tests on Swiper 14.2.0 was:
Simplified desktop example: :root {
--content-width: min(1000px, calc(100vw - 128px));
}
.content-container {
width: var(--content-width);
margin-inline: auto;
}
.projects-swiper {
width: 100%; /* full-width parent, NOT .content-container */
overflow: hidden;
}
.projects-swiper .swiper-slide {
width: calc((var(--content-width) - 25px) / 2);
}const el = document.querySelector('.projects-swiper');
const content = document.querySelector('.content-container');
const offset = () =>
(el.clientWidth - content.getBoundingClientRect().width) / 2;
new Swiper(el, {
loop: true,
loopAdditionalSlides: 2,
speed: 400,
spaceBetween: 25,
slidesPerView: 'auto',
centeredSlides: false,
slidesOffsetBefore: offset,
slidesOffsetAfter: offset,
});See the official offset options and loop slide-count requirements. The required slide count/buffer depends on your geometry; Recordings of the isolated reproduction (Chrome on macOS, 8 cards, 1000 px content container, 25 px gap):
01-loop-comparison.mp4
02-wide-drag-version-comparison.mp4Updating alone is not enough: the original layout still reproduced the issue on 14.2.0. With the layout changes, 14.2.0 passed my initial-state, 24-next/24-prev and 10-wide-drag checks. On 12.0.3, sequential transitions passed but 3 of 10 wide drags still lost a neighbor, so I would not call this a complete workaround for that version. This is a reconstruction, not your actual site; autoplay and the external lazy-loader were excluded from these controlled checks. Which Swiper version and how many slides are you using? Could you share a minimal demo including the HTML/CSS so this can be checked against your exact setup? |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I'm trying to display the prev and next slides from each side of my container. It displaying correctly until the very last slide :
When we reach the end of the slider there is no more prev slide. Here's what it looks like :
What my settings look like :
If I put slidesPerView: 2.1, I have the desired effect, but my slides are not centered anymore in my container :
So I want to know, Is it possible to always have the next and prev slide visible outside of a container. Anyone did this and can help?
Thanks!
All reactions