Components
41
Accordion Block Benifits Grid Block 404 Card Stack Careers Grid Case Study Carousel Case Study Hero Content Columns Content Image Content Image Accordion Content Video Cta Block Example Featured Blog Hero Featured Resource Hero Form Cta Form Hero Full Width Image Homepage Hero Hover List Image Hero Image Mask Image Testimonial Carousel Industry Insights Latest News List Columns Logo Scroller Map Block Post Feed Resource Grid Split Hero Split Text Statement Statistics Row Team Filter Team Grid Testimonial Carousel Testimonial Carousel Text Highlight Tools Grid Two Column List

Statistics Row

View example
50%

increase in conversion value (£110,000+ in new revenue)

16%

increase in ROAS

17%

increase in ad spend - but significantly more efficient output

165%

Increase in average order value

There are no ACF fields assigned to this component.

				
@import "../../resources/scss/util/variables";
@import "../../resources/scss/util/mixins";
@import "../../resources/scss/vendor/bootstrap/vendor/rfs";

.block-statistics-row {
	padding-top: clamp(rem-calc(30), 5vw, rem-calc(100));
	padding-bottom: clamp(rem-calc(30), 5vw, rem-calc(100));

	.content-styles {
		.block-statistics-row__statistic-text {
			p {
				font-size: clamp(rem-calc(18), 2vw, rem-calc(24));
				line-height: 1.3;
				font-weight: 400;
			}
		}
	}

}
class StatisticsRow {
	/**
	 * Create and initialise objects of this class
	 * @param {object} block
	 */
	constructor(block) {
		this.block = block;
		this.init();
	}

	init() {
		// Get all statistic figures within this block
		const figures = this.block.querySelectorAll('.statistics-row__statistic-figure');

		figures.forEach(figure => {
			this.animateStatistic(figure);
		});
	}

	/**
	 * Animate a single statistic figure
	 * @param {HTMLElement} figure
	 */
	animateStatistic(figure) {
		// Get the original text content
		const originalText = figure.textContent.trim();

		// Extract the numeric value and any text prefix/suffix
		const match = originalText.match(/^([^\d]*)(\d+(?:[.,]\d+)?)([^\d]*)$/);

		if (!match) {
			// If no number found, don't animate
			return;
		}

		const prefix = match[1];
		const numberStr = match[2];
		const suffix = match[3];

		// Convert to number (handle both comma and period decimals)
		const targetValue = parseFloat(numberStr.replace(',', '.'));

		// Determine if the original number has decimals
		const hasDecimals = numberStr.includes('.') || numberStr.includes(',');
		const decimalPlaces = hasDecimals ? numberStr.split(/[.,]/)[1].length : 0;

		// Create an object to animate
		const counter = { value: 0 };

		// Set initial display to 0
		figure.textContent = prefix + '0' + suffix;

		// Create the ScrollTrigger animation
		gsap.to(counter, {
			value: targetValue,
			duration: 2,
			ease: "power2.out",
			scrollTrigger: {
				trigger: figure,
				start: "top 80%", // Start when the element is 80% down the viewport
				toggleActions: "play none none none", // Only play once
				once: true // Only trigger once
			},
			onUpdate: function() {
				// Format the number based on whether it had decimals
				let displayValue;
				if (hasDecimals) {
					displayValue = counter.value.toFixed(decimalPlaces);
				} else {
					displayValue = Math.floor(counter.value);
				}

				// Update the text with prefix and suffix
				figure.textContent = prefix + displayValue + suffix;
			}
		});
	}
}

document.addEventListener('DOMContentLoaded', () => {
	document.querySelectorAll('.block-statistics-row').forEach( block => new StatisticsRow(block) );
});
{
    "$schema": "https://schemas.wp.org/trunk/block.json",
    "apiVersion": 2,
    "name": "strategiq/statistics-row",
    "title": "Statistics row",
    "description": "Statistics row block",
    "category": "strategiq",
    "icon": "strategiq",
    "acf": {
        "mode": "edit",
        "renderTemplate": "block-statistics-row.php"
    },
    "supports": {
        "anchor": true,
        "align": false,
		"mode": false,
        "color": {
            "background": true,
            "text": false,
            "gradients": true
        },
        "spacing": {
            "padding": [
				"top",
				"bottom"
			],
            "margin": [
                "top",
                "bottom"
            ]
        }
    },
    "style": "file:../../assets/css/statistics-row/block-statistics-row.css"
}
Page Title
Page Type
Page URL
TOTUM: More sign-ups, less spend
case_studies
Native Communities
case_studies
There are is no readme file with this component.