Loader Split Counter
Create a full-screen GSAP loader with a rolling three-digit counter and dual progress bars.

Initializing the project
Let's start by creating a new Next.js application. Run the following command in your terminal:
Install GSAP for animations and Sass for styling (optional):
Component structure
Create a folder `components/LoaderSplitCounter` with two files: `index.tsx` and `style.module.scss`. Below is the basic JSX structure – note the refs that will be used for animations.
Preparing the counter digits
Each column needs a list of digits to scroll through. The first column goes from 0 to 1 (two digits). The second column cycles 0-9 twice and ends at 0. The third column rolls through 0-9 twice plus a final 0.
Inside the component, generate the third array using `useMemo` and render the digits inside each `.digit` container. Remember to apply the offset classes for proper alignment of certain digits.
Core GSAP animations
All animations are orchestrated inside a `useEffect` using GSAP's context to easily clean up. We'll break them into logical groups: counter scroll, loader growth, loader transformation, and final reveal.
The `animateCounter` helper scrolls a digit container by calculating the total height based on its children:
Using the component
Place the `LoaderSplitCounter` component in your root layout or any page where you want the loading screen to appear. Make sure to use `'use client'` because of the GSAP animations.
You can customize the images, text, and animation timings by tweaking the delay and duration values in the GSAP timeline. For example, change the loader explosion distance or the counter scroll speed to match your brand.
Wrapping Up
Special thanks to the original inspiration and the CodeGrid . Happy coding!
