Zazz Design Framework
Components

Reveal

Scroll-based viewport entry animations using IntersectionObserver and CSS transitions.

Reveal triggers CSS entry transitions using IntersectionObserver when elements scroll into the viewport.

How it works

  1. Add data-reveal or data-reveal-each to HTML elements.
  2. The Reveal script observes elements and sets calculated CSS delay variables.
  3. When scrolled into view, the element receives the .in-viewport class.
  4. CSS transitions in reveal.css animate the element to visible.

Setup

Load index.js as an ES module and include index.css:

<link rel="stylesheet" href="./zazz/index.css" />
<script type="module" src="./zazz/index.js"></script>

Reveal initializes automatically when the DOM loads.

Single elements

<div data-reveal="slide-up">Slides up into view</div>
<div data-reveal="fade">Fades in</div>
<div data-reveal="slide-left">Slides in from right</div>

Animation types

ValueEffect
slide-upTranslate up from below
slide-downTranslate down from above
slide-leftTranslate left from the right
slide-rightTranslate right from the left
fadeOpacity fade
growScale up from smaller
shrinkScale down from larger

Stagger groups

Animate child elements sequentially using data-reveal-each:

<div data-reveal-each="fade" data-reveal-step="100">
  <div>Item 1 (first)</div>
  <div>Item 2 (100ms delay)</div>
  <div>Item 3 (200ms delay)</div>
</div>

Set data-reveal-order="reversed" to animate children in reverse order.

Element transition isolation

Reveal controls transition-* properties to handle delays and durations. To apply hover transitions (such as borders or background changes) without conflicting with scroll reveals, place the reveal attribute on a parent container:

<div data-reveal-each="slide-up">
  <a class="bg-card border rounded-md transition hover:border-primary">Card 1</a>
  <a class="bg-card border rounded-md transition hover:border-primary">Card 2</a>
</div>

Configuration attributes

AttributeDefaultPurpose
data-reveal-duration--ui-reveal-global-durationAnimation duration
data-reveal-wait0Base delay before starting (ms)
data-reveal-step80Delay step between children (ms)
data-reveal-ease--ui-reveal-global-easeTiming function
data-reveal-distance1remSlide translation distance
data-reveal-scaleNoneScale value for grow/shrink
data-reveal-margin0pxObserver rootMargin
data-reveal-threshold0.2Intersection threshold (0 to 1)
data-reveal-orderNoneSet to "reversed" for reversed stagger sequence

Global tokens

:root {
  --ui-reveal-global-duration: var(--default-transition-duration);
  --ui-reveal-global-ease: var(--default-transition-timing-function);
  --ui-reveal-global-wait: 0ms;
  --ui-reveal-global-distance: 1rem;
  --ui-reveal-global-grow: 0.97;
  --ui-reveal-global-shrink: 1.03;
}

Dynamic updates

To observe newly inserted DOM elements:

Reveal.getAutoInstance()?.refresh();

On this page