Scroll Animations
fade • zoom • slide
Onload
Waits ≈ declared delay; here: delay-2s
. Adjust speed with --anim-dur
.
class="anim fade-in onload delay-2s"
Scoll Animations
Scroll animation system provides class-based triggers for smooth, accessible effects.
Animations are activated when elements cross into view, using percentage-based triggers (atNN) or automatic on-load activation (onload).
- Fade – fade-in / fade-out with optional trigger point: fade-in-at60.
- Zoom – zoom-in / zoom-out with adjustable scale: zoom-in2-at70.
- Slide – slide-in|out-(up|down|left|right) with optional distance: slide-in-right-d64-at50.
- Trigger Point (-atNN) – percentage of viewport height where the effect starts (e.g., at80 = 80% down the screen).
- Distance (-dNN) – pixel offset for slide animations (e.g., d200 = 200px).
- Timing – control duration with --anim-dur or utilities: anim-slow, anim-fast, anim-snail.
- Delays – add delay-1s, delay-2s, etc. to sequence animations.
- Stagger – apply a staggered effect to children: stagger-fade-in-at80, stagger-slide-in-right.
- One-shot – add one-shot to run once and not repeat on scroll back.
Combine effects for layered motion (e.g., fade-in-at70 slide-in-up-d128-at70).
Guide & Reference
Cheat sheet
onload
— run after page load (respects delay; total ≈ declared delay)-atNN
— run when element top reaches NN% of viewport (e.g. fade-in-at60
).atNN
— set default trigger on a container (children inherit if they lack -at
)fade-in
, fade-out
zoom-in10
, zoom-out20
(number = % amount)slide-(in|out)-(left|right|up|down)
[-d{px}
]one-shot
— fire once, never revertstagger-effect-atNN
[+ stagger-reverse
]delay-200
| delay-0_5s
| delay-2s
(underscore for decimals)--anim-dur
— duration (e.g. 600ms
)--anim-delay
— set by delay-*
classes--anim-stagger-step
— stagger gap (default 120ms
)Delay behavior
- Onload: we wait roughly
(declared delay − duration)
, then start the transition with no extra CSS delay. Net time to fully visible ≈ your declared delay. - Scroll triggers: we toggle active immediately on trigger; CSS delay runs inside the transition. Perceived wait ≈ your declared delay.
- Accepted formats:
delay-200
(ms),delay-0_5s
,delay-1_5s
,delay-2s
.
Effect combos & conflict rules
- Slide-ins already fade-in. Prefer
slide-in-*
alone, or pair withfade-out
for exit. Avoidfade-in
+slide-in
together unless you want extra opacity easing. - fade-out dominates other effects when active (we turn off fade-in/zoom/slide-in so the element can disappear cleanly).
Tips
- Per-element speed: set
style="--anim-dur: 1200ms"
or make utility classes (e.g.,.anim-slow
,.anim-fast
). - Default trigger via container: wrap items in
.at55
so any child without-atNN
uses 55%. - Accessibility: focus/keyboard users are kept visible (see
.anim:focus-within
rule).
Fade In / Out @ thresholds
Triggers when the element’s top reaches the given % of viewport height.
class="anim fade-in-at75"
class="anim fade-in-at50 fade-out-at20"
class="anim one-shot fade-in-at60"
class="anim fade-in-at25 delay-200"
class="anim fade-in-at35 delay-0_3s"
Zoom
zoom-in10
= start at ~0.90 scale → 1.00. zoom-out20
= start at ~1.20 → 1.00.
class="anim zoom-in10-at50"
class="anim zoom-in20-at50"
class="anim zoom-out10-at50"
class="anim zoom-out20-at50 fade-out-at20"
Slide In / Out (directions + distance)
Slide-ins already include opacity. Use -d{px}
to override distance.
Animation Speed Utilities
These examples use .anim-slow
, .anim-fast
, .anim-snail
, and .anim-instant
.
0ms duration
300ms duration
1200ms duration
3000ms duration
Default Trigger via .atNN
Container has .at55
, children inherit 55% when their effect has no explicit -atNN
.
class="anim fade-in"
class="anim zoom-in10"
Stagger
Applies effect to children, offset by --anim-stagger-step
(default 120ms). Add stagger-reverse
to reverse order.
stagger-fade-in-at80
- One
- Two
- Three
- Four
- Five
class="stagger-fade-in-at80"
stagger-fade-in-at80 + stagger-reverse
- One
- Two
- Three
- Four
- Five
class="stagger-fade-in-at80 stagger-reverse"
Combined Examples
Common patterns that play nicely with the conflict rules.