Global Elements
2
Footer Header Services Strip Services Tabs
Components
36
Card Carousel Cards Grid Content Overlap Content Strip Cta Bar Featured Article Featured Blocks Featured Expert Featured Pods Featured Tabs Form Block Full Screen Carousel Full Width Content Heading Strip Hero Hero Featured Links List Location Tabs Logo Carousel Map Block People Grid Quote Block Reviews Carousel Reviews Tabs Service Tiles Services Strip Services Tabs Staggered Content Sticky Accordion Sticky List Sub Navigation Team Carousel Team Filters Team Strip Tile Carousel Tile Grid

Card Carousel

Field
Field Type
Field Name
Instructions
Block Data
tab
Heading Type
select
heading_type
Heading Text
text
heading_text
Link
link
link
Block Meta
tab
ID
text
block_id
Block Classes
text
block_classes
Block Theme
select
block_theme
Background Colors
select
background_colors
Padding Top
select
padding_top
Padding Bottom
select
padding_bottom
Margin Top
select
margin_top
Margin Bottom
select
margin_bottom

				
@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();
Page Title
Page Type
Page URL

Animation / States

  • As the user scrolls to this component the images will be lazyloaded and the block elements will fade in one by one
  • The carousel will scroll horizontally one at a time using the arrow buttons.
  • The carousel will overflow on the right hand side of the screen

External Libraries

  • Swiper
  • ScrollTrigger (GSAP)

Notes (Design / Dev / SEO)

No notes.