Skip to content

stagger

stagger is the StaggeredMotion equivalent: it builds a GSAP timeline from a keyframe spec so bits do not hand-write per-element tweens.

import { stagger } from "hyperbits/helpers";
const timeline = stagger("#list li", {
y: [40, 0],
opacity: [0, 1],
duration: 0.6,
stagger: 0.08,
ease: "power2.out",
});

Times are seconds. The returned timeline is paused unless you pass an existing timeline.

targets may be a selector, element, array, NodeList, or HTMLCollection.

FieldType
x y rotate rotation scale opacitynumber or number[]
durationseconds, default 0.5
delayseconds
staggerseconds between items
staggerDirection"forward" | "reverse" | "center" | "random"
holdextra seconds after each tween
easeGSAP ease name or function
from / toextra GSAP vars

Two-value arrays become fromTo. Longer arrays become keyframe tweens.

resolveTargets(targets, root?) and calculateStaggerIndex(index, total, direction) are exported for custom sequencing.