Zazz Design Framework
base

View transitions

Built-in page transitions using the Navigation API and View Transitions API.

Zazz provides multi-page view transitions without client framework requirements. When navigating same-origin links, <main> content updates with animated transitions while persistent chrome (header and footer) remains stationary.

Architecture

  1. Navigation API: Intercepts same-origin link clicks and swaps <main> content via fetch().
  2. View Transitions API: Wraps the DOM update in animation curves.

Setup

Include the stylesheet and index.js (which bundles navigation.js):

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

Add transition attributes to header and footer elements (<main> receives transition properties automatically):

<header data-transition-layer="global-header">...</header>
<main>...</main>
<footer data-transition-layer="global-footer">...</footer>

Transition tokens

Animation duration defaults to 0ms. Set --view-transition-duration on :root to activate:

:root {
  --view-transition-duration: 400ms;
  --view-transition-scale--old: 0.98;
}
TokenDefaultDescription
--view-transition-duration0msAnimation duration (set > 0ms to enable)
--view-transition-easevar(--bezier-easing)Easing curve
--view-transition-wait0msDelay before incoming animation
--view-transition-origincenter topTransform origin
--view-transition-scale--old1Scale of outgoing content
--view-transition-scale--new1Scale of incoming content
--view-transition-translate--old0, 0, 0translate3d of outgoing content
--view-transition-translate--new0, 0, 0translate3d of incoming content
--view-transition-opacity--old0Final opacity of outgoing content
--view-transition-opacity--new0Starting opacity of incoming content

Transition behavior

Layer nameTransition mode
main-contentAnimated: outgoing content fades out, incoming fades in
global-headerStatic: retained across navigations
global-footerStatic: retained across navigations

navigation.js handles qualifying same-origin link clicks:

  1. Intercepts navigate events.
  2. Fetches destination HTML and extracts <main>.
  3. Calls document.startViewTransition() to swap DOM nodes.
  4. Updates document.title, restores scroll position, triggers Reveal.refresh(), re-initializes carousels, and focuses the new <h1>.

Fallback behavior

  • No Navigation API: Performs standard full-page load.
  • No View Transitions API: Swaps content immediately without animation.
  • prefers-reduced-motion: Content swaps instantly without transforms.

On this page