@import "../../resources/scss/util/colours";
@import "../../resources/scss/util/variables";
@import "../../resources/scss/util/mixins";
.block-card-carousel {
padding-top: rem-calc(80);
padding-bottom: rem-calc(120);
overflow: hidden;
border-bottom: 1px solid $lightBlue;
.swiper {
overflow: visible;
}
.swiper-slide {
@include bp($lg) {
width: auto !important;
}
}
.heading {
@include fluid-type(28, 34);
@include bp($lg) {
margin-bottom: 0;
}
}
&__intro {
margin-bottom: rem-calc(48);
}
&__buttons {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
@include bp($lg) {
justify-content: flex-end;
width: auto;
}
}
}
class cardCarousel {
/**
* Create and initialise objects of this class
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor
* @param {object} block
*/
constructor() {
this.blocks = document.querySelectorAll('.block-card-carousel');
this.init();
}
init() {
this.blocks.forEach((block) => {
const blockCarousel = block.querySelector(".swiper");
const navNext = block.querySelector(".e-carousel__next");
const navPrev = block.querySelector(".e-carousel__prev");
const swiper = new Swiper(blockCarousel, {
loop: true,
slidesPerView: 1.5,
spaceBetween: 15,
navigation: {
nextEl: navNext,
prevEl: navPrev,
},
// speed: 3000,
breakpoints: {
992: {
slidesPerView: 'auto',
},
// 992: {
// slidesPerView: 5,
// }
}
});
// Staggered reveal animation
const staggeredCards = document.querySelectorAll(".st-stagger-reveal");
if (staggeredCards !== null) {
gsap.set(".st-stagger-reveal", {y: 100});
ScrollTrigger.batch(".st-stagger-reveal", {
start: "top 100%",
onEnter: batch => gsap.to(batch, {opacity: 1, y: 0, stagger: 0.15, overwrite: true}),
onLeave: batch => gsap.set(batch, {opacity: 0, y: -100, overwrite: true}),
onEnterBack: batch => gsap.to(batch, {opacity: 1, y: 0, stagger: 0.15, overwrite: true}),
onLeaveBack: batch => gsap.set(batch, {opacity: 0, y: 100, overwrite: true})
});
ScrollTrigger.addEventListener("refreshInit", () => gsap.set(".st-stagger-reveal", {y: 0}));
}
});
}
}
new cardCarousel();
No notes.