Вот решение, которое я узнаю:
const specialSlider = new Swiper('.special-slider', {
loop: true,
speed: 1000,
slidesPerView: 'auto',
spaceBetween: 0,
centeredSlides: true,
navigation: {
nextEl: '.special-slider__next',
prevEl: '.special-slider__prev',
},
watchOverflow: true,
grabCursor: true,
on: {
init: makeSlidesTransparent,
slideChangeTransitionStart: makeSlidesTransparent,
}
});
function makeSlidesTransparent() {
//Hide old slides
const oldSlides = d.getAll('.special-slider__item.js-visible');
for (let i = 0; i < oldSlides.length; i++) {
oldSlides[i].classList.remove('js-visible')
}
const width = window.innerWidth;
if (width >= 0 && width < 960) {
//Make visible new slides
const activeSlide = d.get('.special-slider__item.swiper-slide-active');
activeSlide.classList.add('js-visible');
}
if (width >= 960 && width < 1700) {
//Make visible new slides
const activeSlide = d.get('.special-slider__item.swiper-slide-active');
const prev1 = activeSlide.previousElementSibling;
const next1 = activeSlide.nextElementSibling;
prev1.classList.add('js-visible');
activeSlide.classList.add('js-visible');
next1.classList.add('js-visible');
}
if (width >= 1700) {
//Make visible new slides
const activeSlide = d.get('.special-slider__item.swiper-slide-active');
const prev1 = activeSlide.previousElementSibling;
const prev2 = prev1.previousElementSibling;
const next1 = activeSlide.nextElementSibling;
const next2 = next1.nextElementSibling;
prev1.classList.add('js-visible');
prev2.classList.add('js-visible');
activeSlide.classList.add('js-visible');
next1.classList.add('js-visible');
next2.classList.add('js-visible');
}
}
И стили:
.special-slider {
&__item {
padding-left: 15px;
padding-right: 15px;
width: 330px;
box-sizing: border-box;
height: auto;
opacity: 0.5;
transition: all $transition-style-slow;
&.js-visible{
opacity: 1;
}
.product-item {
background-color: rgba(218, 215, 205, 0.2);
}
}
}