@import "../../resources/scss/util/variables";
@import "../../resources/scss/util/mixins";
@import "../../resources/scss/vendor/bootstrap/vendor/rfs";
.block-events-carousel {
overflow: hidden;
&__meta {
display: flex;
flex-direction: row;
gap: rem-calc(16);
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
@include margin-bottom( rem-calc(60) );
.heading {
margin-bottom: 0;
}
.btn {
margin-right: 0;
}
}
.swiper {
overflow: visible;
&.swiper-initialized {
display: flex;
}
&:not(.swiper-initialized) {
.swiper-wrapper {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
.swiper-slide {
width: 100%;
}
}
}
}
.swiper-slide {
display: flex;
@include bp($md) {
aspect-ratio: 1720/800;
}
}
}
class EventsCarousel {
/**
* @param {object} block
*/
constructor( block ) {
this.block = block;
this.swiper = null;
ScrollTrigger.create({
trigger: this.block,
start: 'top bottom',
end: 'bottom top',
onEnter: () => this.initialiseSwiper(),
});
}
initialiseSwiper() {
if ( this.swiper ) {
return;
}
this.swiper = new Swiper( this.block.querySelector( '.swiper' ), {
slidesPerView: 1,
spaceBetween: 16,
centeredSlides: true,
speed: 600,
navigation: {
nextEl: this.block.querySelector( '.swiper-button-next' ),
prevEl: this.block.querySelector( '.swiper-button-prev' ),
},
breakpoints: {
600: {
slidesPerView: 1.05,
spaceBetween: 16,
},
768: {
slidesPerView: 1.05,
spaceBetween: 16,
},
992: {
slidesPerView: 1.1,
spaceBetween: 16,
},
1400: {
slidesPerView: 1.1,
spaceBetween: 30,
},
}
});
}
}
document.querySelectorAll('.block-events-carousel').forEach((block) => {
new EventsCarousel( block );
});
Animation: