#why image viewtransition not working in astro v4

4 messages · Page 1 of 1 (latest)

unreal spoke
#

why image viewtransition not working in astro v4

exotic nightBOT
#

Hi @unreal spoke. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information provided in the extracts, there could be several reasons why the image view transition is not working in Astro v4. Here are a few possibilities:

  1. Directives only work in .astro files: According to a comment (https://github.com/withastro/astro/issues/8983) on GitHub, the transition: directives (and all directives, such as client:) only work inside of .astro files. If you're trying to use these directives in a .jsx file, they won't work. Instead, you can use CSS to create a shared class name for the transition.
.my-image {
  view-transition-name: noenemies2;
}
  1. Dynamic view-transition-name: If the view-transition-name needs to be dynamic (such as for multiple images on the page), this is not supported via shared CSS classes. In this case, a dynamic view-transition-name can be added via an inline style property, to ensure unique transition name keys.
<img
  {src}
  {width}
  style={`view-transition-name: ${src.replace(/[^a-z0-9]/gi, '')}`}
/>
  1. Issues with <ViewTransitions />: There have been reported issues (https://github.com/withastro/astro/issues/9368) with the <ViewTransitions /> component causing errors. If you're using this component, it could be the source of the problem.

  2. Discrepancies between dev and prod: There have been reports (https://discord.com/channels/830184174198718474/1151397066212388924) of view transitions working in development but not in production. This could be due to differences in the environments or configurations.

#

If none of these solutions work, you may want to check Astro’s issues on GitHub (https://github.com/withastro/astro/issues/) for any reported issues, or to file an issue yourself.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: