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

Cards Grid

Field
Field Type
Field Name
Instructions
Block Data
tab
Featured Items
relationship
featured_items
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-cards-grid {
	padding-top: rem-calc(80);
	padding-bottom: rem-calc(80);

	.e-block {
		margin-bottom: rem-calc(40);

		@include bp($lg) {
			width: auto;
			height: auto;
			padding-top: (287 / 477) * 100%;
			margin-bottom: rem-calc(80);
		}
	}
}
class CardsGrid {
	/**
	 * 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-cards-grid');
		this.init();
	}

	/**
	 * Example function to run class logic
	 * Can access `this.block`
	 */
	init() {
		this.blocks.forEach((block) => {
			const featuredBlocks = block.querySelectorAll(".e-block");

			if (featuredBlocks !== null)  {
				gsap.set(".block-cards-grid .e-block", {y: 50, opacity: 0});

				ScrollTrigger.batch(".block-cards-grid .e-block", {
					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-cards-grid .e-block", {y: 0}));
			}
		});
	}
}

new CardsGrid();
Page Title
Page Type
Page URL

Animation / States

  • As the user scrolls to this component the items will be lazyloaded and fade in one by one
  • On hover the image will slowly scale up
  • On hover the box containing the title will animate up and reveal a brief description

External Libraries

  • ScrollTrigger (GSAP)

Notes (Design / Dev / SEO)

No notes.