import { useEffect } from "react"; import { Power1, gsap } from "gsap"; import { ScrollTrigger } from "@/plugins"; gsap.registerPlugin(ScrollTrigger); const AboutCounter = () => { useEffect(() => { if (typeof window !== "undefined") { let device_width = window.innerWidth; let tHero = gsap.context(() => { gsap.set(".counter_animation .counter__anim", { y: -100, opacity: 0 }); if (device_width < 1023) { const counterArray = gsap.utils.toArray( ".counter_animation .counter__anim" ); counterArray.forEach((item, i) => { let counterTl = gsap.timeline({ scrollTrigger: { trigger: item, start: "top center+=200", }, }); counterTl.to(item, { y: 0, opacity: 1, ease: "bounce", duration: 1.5, }); }); } else { gsap.to(".counter_animation .counter__anim", { scrollTrigger: { trigger: ".counter_animation", start: "top center+=300", }, y: 0, opacity: 1, ease: "bounce", duration: 1.5, stagger: { each: 0.3, }, }); } for (let i = 1; i < 5; i++) { gsap.from(gsap.utils.toArray(`.count${i}`), { textContent: 0, duration: 1, delay: 0.2, ease: Power1.easeIn, snap: { textContent: 1 }, stagger: 1, scrollTrigger: { trigger: `.counter__number`, }, }); } }); return () => tHero.revert(); } }, []); return ( <>

25k

Project
completed

8k

Happy
customers

15

Years
experiences

98

Awards
achievement

); }; export default AboutCounter;