(function (global) { const { useState, useEffect, useRef } = React; function CountUpValue({ target, suffix, formatComma }) { const [displayVal, setDisplayVal] = useState(target); const hasAnimatedRef = useRef(false); const elRef = useRef(null); useEffect(() => { const node = elRef.current; if (!node || typeof IntersectionObserver === 'undefined') return; const observer = new IntersectionObserver( (entries) => { if (entries[0].isIntersecting && !hasAnimatedRef.current) { hasAnimatedRef.current = true; const duration = 900; const start = performance.now(); const tick = (now) => { const progress = Math.min((now - start) / duration, 1); const eased = 1 - Math.pow(1 - progress, 3); setDisplayVal(Math.round(eased * target)); if (progress < 1) { requestAnimationFrame(tick); } }; requestAnimationFrame(tick); observer.disconnect(); } }, { threshold: 0.25 } ); observer.observe(node); return () => observer.disconnect(); }, [target]); const formatted = formatComma ? displayVal.toLocaleString('en-CA') : String(displayVal); return ( {formatted} {suffix} ); } function StatsStrip() { const stats = [ { target: 1500, suffix: '+', formatComma: true, label: 'Inspected' }, { target: 10, suffix: '+', formatComma: false, label: 'Years Experience' }, { target: 98, suffix: '%', formatComma: false, label: 'Client Satisfaction' }, { target: 24, suffix: 'Hr', formatComma: false, label: 'Report Delivery' }, ]; return (
{stats.map((stat) => (
{stat.label}
))}
); } global.ShieldPointComponents = global.ShieldPointComponents || {}; global.ShieldPointComponents.StatsStrip = StatsStrip; })(window);