Skip to content

Add Astro View Transitions for smooth client-side navigation#206

Draft
sergeychernyshev wants to merge 1 commit into199-separate-pagesfrom
view-transitions
Draft

Add Astro View Transitions for smooth client-side navigation#206
sergeychernyshev wants to merge 1 commit into199-separate-pagesfrom
view-transitions

Conversation

@sergeychernyshev
Copy link
Copy Markdown
Member

@sergeychernyshev sergeychernyshev commented Mar 17, 2026

Summary

  • Enables Astro's built-in View Transitions (<ViewTransitions />) across the entire site to eliminate full-page reloads when navigating between pages
  • Adds transition:name / transition:animate directives to the shared ResultLayout so the header, overview, and tab nav stay stable while tab content crossfades
  • Wraps all interactive <script> bodies in astro:page-load event handlers so event listeners re-bind after client-side DOM swaps

Depends on

This PR is based on the 199-separate-pages branch (dedicated tab URLs). It should be merged after that branch lands.

Details

Problem: With the new per-tab URL structure, every tab switch is a full page navigation. The entire page (header, overview panel, screenshot, tab nav) flashes and re-renders even though only the tab content changes.

Solution: Astro View Transitions intercept link clicks and perform client-side DOM diffing instead of full reloads. Elements with matching transition:name attributes morph in place; the tab content area uses transition:animate="fade" for a smooth crossfade.

Scripts fix: Astro's client router only executes <script> modules once. After a soft navigation, the DOM is swapped but scripts don't re-run, leaving new elements without event listeners. All interactive scripts are now wrapped in document.addEventListener('astro:page-load', ...) which fires on initial load AND after every client-side navigation.

Files changed

File Change
Layout.astro Added <ViewTransitions /> to <head>
index.astro Added <ViewTransitions /> (standalone page)
ResultLayout.astro transition:name/transition:animate on header, title, overview, tab content
Tabs.astro transition:name on tab nav
TopNav.astro astro:page-load wrapper for theme toggle
results.astro astro:page-load wrapper for list/grid switcher
upload.astro astro:page-load wrapper for upload form
AllMetrics.astro astro:page-load wrapper for legend/diagram interactions
Console.astro astro:page-load wrapper + duplicate button guard
Resources.astro astro:page-load wrapper for filters
Waterfall.astro astro:page-load wrapper + state reset on navigation

Closes #199

✨ AI-assisted

Enable Astro's built-in View Transitions across the site to eliminate
full-page reloads when navigating between pages.

- Add <ViewTransitions /> to Layout.astro and index.astro
- Add transition:name/animate directives to ResultLayout for stable
  chrome (title, overview, tabs nav) with fade on tab content
- Wrap all interactive <script> bodies in astro:page-load handlers so
  event listeners re-bind after client-side DOM swaps (theme toggle,
  list/grid switcher, resource filters, console filters, metrics
  legend, waterfall init, upload form)
- Reset Waterfall component state on each navigation
- Guard Console filter button creation against duplicates
@sergeychernyshev sergeychernyshev marked this pull request as draft March 17, 2026 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant