Skip to content

Conversation

@ArmandPhilippot
Copy link
Member

@ArmandPhilippot ArmandPhilippot commented Nov 18, 2025

Description (required)

Not documented

  • ClientRouterModule, TransitionModule from astro:transitions: although importable those are internal types
  • EventModule, TransitionRouterModule, TransitionSwapFunctionModule from astro:transitions/client: although importable those are internal types
  • type Options: I think it makes more sense to details the properties under navigate() so I wasn't sure how to document the type. I left it in the available imports from astro:transitions/client though.
  • The TransitionAnimation, TransitionAnimationPair, TransitionAnimationValue, TransitionDirectionalAnimations types (currently partially displayed in the guide) because they are exported from astro, not astro:transitions.

Related issues & labels (optional)

  • Suggested label: add new content, improve or update documentation

@netlify
Copy link

netlify bot commented Nov 18, 2025

Deploy Preview for astro-docs-2 ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit adb4db1
🔍 Latest deploy log https://app.netlify.com/projects/astro-docs-2/deploys/691dc9380ea1400008f4d3da
😎 Deploy Preview https://deploy-preview-12734--astro-docs-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@astrobot-houston
Copy link
Contributor

astrobot-houston commented Nov 18, 2025

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
en/guides/view-transitions.mdx Source changed, localizations will be marked as outdated.
en/reference/modules/astro-transitions.mdx Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@ArmandPhilippot ArmandPhilippot added improve or update documentation Enhance / update existing documentation (e.g. add example, improve description, update for changes) add new content Document something that is not in docs. May require testing, confirmation, or affect other pages. labels Nov 18, 2025
<div transition:animate={slide({ duration: '0.4s' })} />
```

### `createAnimationScope()`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole section and the code snippet might need a review from someone used to view transitions (and Astro's implementation). This is my understanding but maybe I'm wrong here. 😅
Also, the code snippet is a bit heavy, but if I understand correctly, we need all of this to have a working example?

<Since v="3.6.0" />
</p>

A constant to avoid writing the `astro:before-preparation` event name in plain text when you define an event.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably for Sarah: I struggled a bit to describe the constants (this one and the followings). I'm not sure this is the best description, but I think those are useful to document.

- Anything else some other listener might have set.
The direction of the transition. This can be a predefined [`Direction`](#direction) or anything else some other listener might have set.

In the [`astro:before-preparation` event](#astrobefore-swap-event), the value is writable and accepts any `string`. In the [`astro:before-swap` event](#astrobefore-swap-event), the value is readonly.
Copy link
Member Author

@ArmandPhilippot ArmandPhilippot Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it true ("some other listener might have set")? I'm not familiar enough with view transitions but from my understanding, this can only be defined inside an astro:before-preparation event so the current description might be confusing?

I reused the wording we had, and added a sentence below to clarify that, although common to both, this attribute does not have the same purpose depending on the event.


**Type:** `FormData | undefined`
**Type:** `FormData | undefined`<br />
**Available in:** [`astro:before-preparation` event](#astrobefore-preparation-event)
Copy link
Member Author

@ArmandPhilippot ArmandPhilippot Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure if this should be plain text or part of the API block, but I think this is helpful to add this information for someone getting there from a direct link, an AI, etc.

@ArmandPhilippot ArmandPhilippot marked this pull request as ready for review November 19, 2025 14:37
@ArmandPhilippot
Copy link
Member Author

Anyone is welcome to review this PR, but I'll ping @matthewp and @martrapp because they know better the view transitions API. If one of you two has the time to check the accuracy of the new sections this would be helpful! No rush!

Context: Some imports weren't documented, at least in the reference page. I added docs for them and fixed some types/since while I was there. The details is available in the first post. You're free to check the whole PR, but your help is especially useful for createAnimationScope() and the direction attribute (see my review comment for why I need you here).

Also, is there a reason for the TransitionAnimation, TransitionAnimationPair, TransitionAnimationValue, TransitionDirectionalAnimations types to be exported from astro instead of astro:transitions?
Not a real issue, I ask the question because it would have been convenient to have them in the same place so that they could be documented on the reference page, and avoid displaying them as a code snippet in the guide.

@martrapp
Copy link
Member

Hi @ArmandPhilippot 👋🏼 thank you for taking care and fixing!

I'm afraid, some of these are long forgotten youthful mistakes and which we should mark them as deprecated:

  • TRANSITION_AFTER_PREPARATION, TRANSITION_AFTER_SWAP, TRANSITION_BEFORE_PREPARATION, TRANSITION_BEFORE_SWAP, TRANSITION_PAGE_LOAD.
    When I introduced them, Matthew told me that Astro does typically not provide constants like this, but I missed the chance to take them out again.
  • isTransitionBeforePreparationEvent, isTransitionBeforeSwapEvent: I found those narrowing function useful for Typescript. That was before I learned from Erika, how this is done right (types/public/view-transitions.ts)

@ArmandPhilippot
Copy link
Member Author

Thanks for the feedback, Martin! Well, even if we end up not documenting them because we prefer to deprecate them, this allows us to identify what we should clean up in a future version! The same thing happened with astro:actions: withastro/astro#14608 😄

@martrapp
Copy link
Member

Also, is there a reason for the TransitionAnimation, TransitionAnimationPair, TransitionAnimationValue, TransitionDirectionalAnimations types to be exported from astro instead of astro:transitions?

Good question, that never really stood out to me. @matthewp?

Direction:

Yes, you are right, this can only be changed in a listener for astro:before-preparation.

Details: For links and form submission, direction is automatically set to forward. History traversals set this to forward or back. The value is available in the TransitionBeforePreparationEvent and can be changed using a listener to astro:before-preparation. The value is used to control the animation direction right before astro:before-swap is dispatched. Listeners to astro:before-swap can still read the value, but in that event, it is write protected.

While normal navigation is forward and back, this limits you to two types of animation on navigation. So, yes, an idea was to support more than those two and hence allowing direction to have arbitrary values. We never pushed that much and integration with Astro scopes and the generated styles is very low-level.

Your createAnimationScope example looks good, but I'll need more time to review ;-)

@florian-lefebvre
Copy link
Member

Armand feel free to create a new issue on the main repo and assign it to the v6 milestone once you know what we should deprecated/remove!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add new content Document something that is not in docs. May require testing, confirmation, or affect other pages. improve or update documentation Enhance / update existing documentation (e.g. add example, improve description, update for changes)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants