@import "../../resources/scss/util/colours";
@import "../../resources/scss/util/variables";
@import "../../resources/scss/util/mixins";
.block-featured-blocks {
padding-top: rem-calc(80);
padding-bottom: rem-calc(80);
overflow: hidden;
.heading {
@include fluid-type(28, 34);
}
&__buttons {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
@include bp($lg) {
justify-content: flex-end;
width: auto;
}
}
&.bg-navy {
.heading {
color: $white;
}
.e-link {
color: $white;
}
.block-card-carousel__buttons {
.e-link {
color: $white;
}
}
}
.single-service & {
background-color: $veryLightBlue;
border-bottom: 1px solid $lightBlue;
}
&__intro {
margin-bottom: rem-calc(28);
}
&__row-01 {
margin-bottom: rem-calc(30);
}
.swiper {
overflow: visible;
}
.swiper-slide {
height: auto;
}
}
class FeaturedBlocks {
/**
* 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-featured-blocks');
this.init();
}
/**
* Example function to run class logic
* Can access `this.block`
*/
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: false,
slidesPerView: 1.5,
spaceBetween: 15,
navigation: {
nextEl: navNext,
prevEl: navPrev,
},
});
const featuredBlocks = block.querySelectorAll(".e-card");
if (featuredBlocks !== null) {
gsap.set(".block-featured-blocks .e-card", {y: 50, opacity: 0});
ScrollTrigger.batch(".block-featured-blocks .e-card", {
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: -50, overwrite: true}),
onEnterBack: batch => gsap.to(batch, {opacity: 1, y: 0, stagger: 0.15, overwrite: true}),
onLeaveBack: batch => gsap.set(batch, {opacity: 0, y: 50, overwrite: true}),
});
ScrollTrigger.addEventListener("refreshInit", () => gsap.set(".block-featured-blocks .e-card", {y: 0}));
}
});
}
}
new FeaturedBlocks();