@loscolmebrothers/loading
v1.1.2
Published
GSAP-powered loading overlay with staggered slice animations — self-contained styles, no Tailwind required
Readme
@loscolmebrothers/loading
GSAP-powered loading overlay with staggered slice animations. Stacks image "slices" vertically, plays an entrance → idle → exit animation lifecycle, and can be driven by either a duration prop or an external finish() trigger.
Installation
pnpm add @loscolmebrothers/loadingStyles are self-contained — the component injects its own scoped CSS at import time, so no Tailwind and no separate stylesheet import are required. Peer dependencies:
{
"react": ">=18",
"react-dom": ">=18",
"gsap": ">=3.12"
}Usage
import { Loading, type LoadingHandle } from "@loscolmebrothers/loading";Duration mode (auto-finish)
<Loading duration={2200} onFinish={() => startScene()} />Trigger mode (caller-controlled)
const ref = useRef<LoadingHandle>(null);
<Loading ref={ref} onFinish={() => startScene()} />
ref.current?.finish();Custom slices
<Loading
slices={[
{ src: "/logo-part-1.svg", alt: "Part 1" },
{ src: "/logo-part-2.svg", alt: "Part 2" },
]}
duration={2200}
onFinish={startScene}
/>Props
| Prop | Type | Default | Description |
| ----------- | --------------------------------- | ---------------- | ------------------------------------------------ |
| slices | LoadingSlice[] | LOS / COLME / BROTHERS | Images stacked vertically |
| className | string | "" | Extra classes on the overlay |
| size | number \| string | 24 | Slice image height (24 → 24px; or any CSS length like "1.5rem"). Width auto-scales. |
| duration | number (ms) | undefined | Auto-finish after N ms. Omit for trigger mode. |
| onFinish | () => void | undefined | Called when loading completes (both modes) |
Handle
finish(onComplete?) — manually trigger the exit animation.
Animation phases
- Entrance — slices rise in with
back.out(1.5), staggered, landing at 50% opacity. - Idle — gentle balloon bob + subtle opacity breathing (0.3 ↔ 0.5, staggered).
- Exit — brief downward drift, then slices rise up and fade, overlay fades out.
Development
pnpm install
pnpm build # tsc → dist/
pnpm dev # watch modeSource lives in src/, compiled output in dist/. npm publish runs the
prepublishOnly build hook, so the registry tarball always ships a fresh build.
