Skip to content

Homepage: let go of the presentations' observers when leaving the page - #1212

Merged
ngnijland merged 1 commit into
masterfrom
claude/homepage-autoplay-cleanup
Oct 10, 2026
Merged

ngnijland merged 1 commit into
masterfrom
claude/homepage-autoplay-cleanup

Conversation

@ngnijland

Copy link
Copy Markdown
Collaborator

Summary

The site uses Astro's ClientRouter, which swaps pages without a reload. The homepage presentations set up observers that were never disconnected, so each client-side visit back to the homepage added another set, and the old ones kept references to the previous page's stages, videos and autoplay state. Nothing broke visibly: the old autoplays stop themselves once their stage is off the page. But the old page's elements could stay in memory.

Each presentation now lets go on astro:before-swap, just before a navigation replaces the page:

Test plan

  • npm run lint, format:check, typecheck, build, knip in docs/; npm test (93 pass)
  • Headless Chrome with wrapped observers, navigating client-side from /home-next/ to /pricing/ and back:
    • First load: 6 stage IntersectionObservers and 4 tabs ResizeObservers.
    • After leaving: all 6 and all 4 disconnected (before: 0).
    • Back again: fresh ones are created, Teams autoplay still advances, and stage swipes still work.

🤖 Generated with Claude Code

The ClientRouter swaps pages without reloading, and nothing disconnected
the observers the homepage presentations set up, so each visit back to
the homepage added more, still holding the old page's stages.

- Autoplay (tabs and gallery) disconnects its IntersectionObserver,
  stops its frame loop and pauses its videos on `astro:before-swap`.
- The closer look does the same for its own observer and videos.
- The tabs drop their ResizeObserver and the list layout's media query
  listener on the same event, instead of keeping a teardown list for the
  next page load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ngnijland
ngnijland merged commit 8cd5c65 into master Oct 10, 2026
1 check passed
@ngnijland
ngnijland deleted the claude/homepage-autoplay-cleanup branch October 10, 2026 06:26
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