New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
View Transitions RFC #607
View Transitions RFC #607
Conversation
|
Can both |
|
Can you explain more why “This approach is not the best for apps”? I don’t like having to use a client router for apps uses cases, you lose the ability to fetch data in the server How do persistent islands update between pages if props change? |
|
@andparsons Keep in mind that you don't need to use these directives, you can write your own animations in plain CSS. So if you wanted to animate some elements within an island you could do so by inserting Of course you might want to use the built-in animations instead of writing it yourself. Currently sharing view transition animations is tricky. It's not as simple as a CSS class. But there is something we can probably do here. Maybe something like this (React example): import { slide, createAnimation } from 'astro:transitions';
export default function() {
const { attrs, styles } = createAnimation('header', slide({ duration: 300 }));
return (
<header {...attrs}>
<style>{styles}</style>
</header>
)
} |
Maybe I should update that section to rephrase it. All I meant there is that it doesn't turn Astro into a SPA framework. There's still islands and separate pages. For some category of apps that are multi-pages this RFC should help. But if you are building a chat app, for example, you probably still want to use a client-side router. Does this explanation help?
That's a good question. My thought was that the old island replaces the new one and that the new props are also copied over. I should update the text to explain this. My expectation is that if props change the island will rerender with them. |
|
Does this mean that Astro is not interested in implementing a client-side router and you have to use thirtparty libraries for that? I can understand that Astro doesn't want to become an SPA framework, but client-side routing improves the experience of website visitors a lot. In this aspect I would have been happy if Astro would offer an optional router. That doesn't have to mean that Astro becomes something else. From my perspective, the router would just be something optional that you can use or not. Basically, I don't think the division between websites and apps is quite right. Why shouldn't a blog or agency website use client-side routing if it improves load times and enables seamless page transitions? Personally, I think it's a shame when you have to switch back to other frameworks in such cases, which are often too complicated, error-prone, or overkill for creating content-based websites. |
|
This RFC does include a client side router. |
sorry only now i understood the connections between View Transition API + Client-side Router. I am very happy about this step. Keep up the good work 👍 |
|
So, I made the page https://gingerarchitecture.cz/ and as soon as the view transition came out, I implemented them.
|
|
There is 1 major thing that needs updating to the RFC before it is ready for consensus: Currently we have 2 events:
The naming on these isn't perfect. Does anyone have opinions on different names? |
|
How about Or if the event is to be really easy to understand |
|
Personally, I think it would be nice to align with the upcoming |
|
What would |
|
Here's the idea I have so far:
What I like about these names is that they are clearly different; the old names were named similarly but are for different points in the lifecycle. I also like using |
|
What do you think about the standing issues highlighted in the #607 (comment) above? |
|
@Akxe Hey, I did see your list, thanks for reminding me. This PR is just about the API so anything that's a bug can be talked about fixed in the main repo. For your animation ideas, we have the ability to customize them via the JS API described in this section: https://github.com/withastro/roadmap/pull/607/files#diff-d291a93498426e7f8d119f703074a53a15a3f73af71b6b1465f114d506ddf4f3R212 We did it this way for a couple of reasons:
So you should have essentially fully control over all of the animations that way. What do you mean by a no-op transition? |
|
I don't think there is a way to make the default No-op transition would be a way to enable animation from one page to another but disable it in reverse... |
|
@Akxe I'll take a look at the morph API and see what we can do. For the no-op idea, we were thinking of adding an attribute, like |
|
@matthewp I honestly don't recall why I needed it. But I have solved in an other way... |
|
@Akxe ok, if you remember the need let me know and I'll try and get it encorporated. |
|
Talked quite a bit with people on discord and realized that the proposed event names were too vague. So trying to be more exact and going with |
|
I'm moving for a call for consensus on this RFC. View transitions has been in experimental since 2.9 and the API has only changed to support persistent islands. This will be the final comment period (3 days); if there are no objections this will be merged and the feature can move out of experimental in 3.0. Note that this doesn't mean no features / improvements can't be added, those will continue. The RFC covers the overall shape of the API. |
|
I only have event name nitpicking. I like |
|
Not 100% sure of the answer, but I do agree with @TheOtterlord re: the event naming.
|
|
I do agree with the comments above. I would like to add my ideas...
|
|
I just realised that the RFC needs a way to opt-out for individual links. I just had a case where I link to a PDF file, and the transition engine tries to make a pretty transition to it, breaking completely... |
|
@Akxe There's a PR up for opting out of individual links. |
|
re: event naming. cc @TheOtterlord @Akxe @delucis One thing to keep in mind is that naming has to make sense both for view transition navigations and for non-VT fallback. So that is one reason to avoid naming things in relation to a step like Another thing to keep in mind is that there will likely be new events in the future. I can see a "start transition" event that gives you the |
|
I agree about
I think I agree with @TheOtterlord that a |
|
I think what I'm going to do is remove the event names from the RFC text, or make it clear that they are tentative names. RFCs are not blocked on naming bikeshedding, that can continue to happen through the PR process. So happy to discuss the exact names to be used in the PR that updates it. |
Why should the names respect the fallback variant? Isn't the fallback in place to fill the time it will take other browsers to implement these features? Do you plan to support the transition of browsers back down from the implementation? |
|
Yeah, I mean we don't have to respect it. But it can also be confusing to people who make think that they are listening to an event that only occurs during a transition and make assumptions based on that. Given that swapping the DOM contents doesn't really have anything to do with a transition; it happens to occur inside of a transition if there is one, is there a benefit with having transition be part of the name? |
|
We already server-render with Alpine.js for client interactions and do SPA-like navigation like this (simplified): If we wanted to switch to this API, we would need a way to "swap" the swap algorithm More example algorithms: https://htmx.org/docs/#morphing API suggestion: |
Shouldn’t these two cases be transparent/equivalent to users? I’d think that when the fallback runs, users code should behave the same. In other words, the fallback behaviour is an Astro implementation detail I don’t want to think about as an API user. I still stand by the argument that when using these APIs “after swap” is likely not a clear concept to a user. Even if we would like people not to rely on this being “before transition” (because it could be non-VT fallback), when documenting we’ll still end up writing stuff like “to ensure something happens before running the transition use the
Reiterating from above that all-lowercase names like |
|
@tropperstyle I think we can likely accommodate custom morphing. That exact API won't work because this code needs to run in the client and the one you show is running on the server. But something else, like perhaps an event could allow you to achieve this. |
For these two events it is transparent, yes. They occur in both. But there could be some events in the future that only happen with an actual transition, such as the case where we include the Our fallback behavior is intended to be a best-effort fallback, it's not intended to be polyfill.
Wouldn't it be clear if we documented swap as a concept and explained what it is, how it works? To be clear, I'm not opposed to use the word transition if others don't think it becomes confusing. I do want to make sure we are accurate however. This event does not occur before the transition. It happens in the middle of it. Looking these docs: https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API#the_view_transition_process the event we're discussing happens in step 2. The browser has already screenshotted the old page.
Sure, happy to bikeshed in the PR. I'll link to it here. Those other options aren't conventional, built-in events are mostly lowercase like this (with some legacy exceptions). But if there's a good reason to break that convention we can do so. |
|
Here's the PR: withastro/astro#8181 we have up to a week to debate :D |
|
The comment period has passed with no objections, so this RFC is merged as approved. Thanks everyone! |
Summary
Provides utilities to ease the usage of view transitions in Astro sites.
Links