-
Notifications
You must be signed in to change notification settings - Fork 50
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
Design an API for the MPA transition #2
Comments
I think we still need a prepare step, so that should remain the same. However, the start call should be replaced with something like
I think we would want to pass the url here, which would initiate the navigation and sharedElement selectors will need to be a list of identifiers that can be used to identify elements on the destination page. It's unclear whether these elements should be specially tagged (ie opt-in style, something like One thing to note is that for SPA, we require paint containment right now, and I think we need that for the MPA case as well. /cc @jakearchibald |
If possible, I think we should avoid triggering the navigation with a new API. There are lots of ways to navigate, some get special privileges, and some modify history state in a particular way. If we create a new API we'll likely lose some of those, or end up with an option bag to try and cover all of those cases. https://github.com/WICG/app-history has a "navigate" event, which sounds like exactly what we'd need.
This makes me wonder if the MPA API would be better in CSS: @nav-transition {
type: reveal;
duration: 300ms;
}
.main-avatar {
nav-transition-id: main-avatar;
}
.header {
nav-transition-id: header;
} Setting Then, when the next page is ready to go, the browser figures out which I'm not sure how you'd specify different nav transitions for different destinations. Maybe you could do that with JS in the "navigate" event. Or, something like: @nav-transition {
type: reveal;
duration: 300ms;
destination: url-prefix('/profile/');
} …where the first
That seems ok, but what's the reason for the requirement? |
Some feedback I got: The 'destination' should be part of the @-rule. We also need to consider how the inclusion of a URL might make it harder to deliver these transitions in the form of a library. |
@jakearchibald (thinking out loud here) How about some generic keywords such as |
Am I right to assume that considering the following example <!-- index.html -->
<html>
<style>
header {
nav-transition-id: header;
height: 100px;
}
main {
nav-transition-id: main;
background: #ccc;
}
</style>
<body>
<header>
<a href="index.html">Home</a>
<a href="red.html">Red</a>
<a href="blue.html">Blue</a>
<a href="about.html">About</a>
</header>
<main>
<h1>Home Page</h1>
</main>
</body>
</html>
<!-- red.html & blue.html (only h1 text content is different) -->
<html>
<style>
header {
nav-transition-id: header;
height: 30px;
}
main {
nav-transition-id: main;
background: red;
}
</style>
<body>
<header>
<a href="index.html">Home</a>
<a href="red.html">Red</a>
<a href="blue.html">Blue</a>
<a href="about.html">About</a>
</header>
<main>
<h1>Red Page</h1>
</main>
</body>
</html>
<!-- about.html -->
<html>
<style>
.fancy-about-page {
/* ... */
}
</style>
<body>
<div class="fancy-about-page">
<h1>About</h1>
<p>...</p>
</div>
<header>
<a href="index.html">Home</a>
<a href="red.html">Red</a>
<a href="blue.html">Blue</a>
<a href="about.html">About</a>
</header>
<main>
<h1>Blue Page</h1>
</main>
</body>
</html> I would expect the following transitions to happen
Is this a right assumption? |
A few things that would be nice to have in this API:
One reason for using a SPA and animating transitions is to make apps feel immediately responsive. If I'm understanding this proposal, it would wait until the next page is ready to execute What would be nice is a two-phase animation. Allow Then, a second
If elements are being animated between both pages, the ideal case would be to finish the transition as soon as all shared elements are available. If the transition is too early, animations may look terrible if some shared elements aren't rendered yet. If we wait until the entire page is rendered, it may add a lot of latency and make SET for MPA feel slow. Perhaps something like renderblocking could be extended to work on elements in the body chunk and used here? Another improvement to the timeline would be to add an additional hook |
Another aspect that is not clear for MPAs is back/forward button navigations. Is there an option to run these animations on subsequent navigations? It might require providing an inverse configuration for the reverse direction. It could also get complicated if the page itself changes before it is re-run, but overall I think the API would be able to be saved and re-executed if needed. |
We were already thinking about entry/exit animations in the context of #37 but your suggestion is more about the timeline on which these animations run. Our current approach is to run all animations on the new Document's timeline once it is ready for first render. While the idea you're proposing is to run some animations at 2 other stages : on the old page once the navigation is initiated and on the new page (using cached content from the old page?) while the new page is being received. Regarding extending renderblocking to include elements in the body chunk. Not sure how yet but we do need a way to know that all shared elements necessary for animations post first render have been fetched. |
And to your point about back/forward navigations, this came up in issue #25 as well. And as you mentioned this gets complicated if the new page changes before the back navigation. Our thinking here is that the developer should be able to configure the transition for a back navigation. app-history would provide a good hook to know when a back navigation is initiated and configure based on current state of the new page. |
anything we can do to help out here? |
Isn't there a large overlap with MPA transitions and I know its not exactly the same thing as being able to carry the same element across MPA boundaries, but you can fake it with It's better to have two independent proposals that compose than to have redundant effort. |
I agree, and in fact many of us working on both proposals sit in the same room. I think an API for shared element transitions between pages makes sense, even though there may be some overlap with portals. |
The SPA transition case has a working API, but it's unclear what the MPA equivalent should look like.
We need to design that
The text was updated successfully, but these errors were encountered: