Repository navigation
Homepage: let go of the presentations' observers when leaving the page - #1212
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:autoplay.ts) disconnects itsIntersectionObserver, cancels its frame loop and pauses its videos. It is self-contained, so the presentations don't need to call anything.ResizeObserverand the list layout's media query listener on the same event. This replaces the module-level teardown list from Homepage: give the feature tabs motion of their own #1207 and Homepage: list the feature tabs beside the stage on wide screens #1208, so all three presentations clean up the same way.Test plan
npm run lint,format:check,typecheck,build,knipindocs/;npm test(93 pass)/home-next/to/pricing/and back:IntersectionObservers and 4 tabsResizeObservers.🤖 Generated with Claude Code