Skip to content
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

FR: Seamless page transitions #12981

Closed
ericlindley-g opened this issue Jan 23, 2018 · 8 comments
Closed

FR: Seamless page transitions #12981

ericlindley-g opened this issue Jan 23, 2018 · 8 comments

Comments

@ericlindley-g
Copy link
Contributor

Developer impl
• Developer opts in/out links on a given page for managed page transitions

User-facing effect
• A more seamless page transition (no white flash, etc)
• Elements that are re-loaded get default loading animation.

AMP Impl
• Get URL
• Copy over script tags
• Replace body with new content ( @cramforce , would the entire document body be replaced, or just elements not common between the old and new doc?)
• pushState the URL (if in a viewer would need to coordinate) — handle back navigation, etc

Limitations
• Only works if the target page is AMP
• May only work on origin (though hopefully can get working from cache / in viewers)

/cc @cramforce @aghassemi @spacedino @choumx

@aghassemi
Copy link
Contributor

So essentially origin-based version of A2A (#12496) ?
We should try to take the same implementation approach for both cases as much as possible. Maybe the only difference is the extra communication needed with the viewer to update its state of the current Url (which we need for Related-Content Infinite Scrolling anyway)

@cramforce
Copy link
Member

cramforce commented Jan 24, 2018 via email

@aghassemi
Copy link
Contributor

Good point, Prototype for Related-Content Infinite Scrolling uses PWA infra. I guess this can be thought of a special case of the same thing, a new doc is loaded but instead of getting appended to the initial doc, it replaces it. @emarchiori

@westonruter
Copy link
Member

• Replace body with new content ( cramforce , would the entire document body be replaced, or just elements not common between the old and new doc?)

Perhaps there should be a way to declaratively identify the regions of the document that should get updated? The title and any metadata would be a given. The class attributes on the body and html would be another good default. But then there'd probably need to be a way to identify the nav menu that would need to be updated, and then the container for the content that changes. Or else do diffing on the entire DOM. This seems quite related to amp-live-list which is a very simple example of dynamically inserting content from another URL based on comparing the two DOM trees.

@westonruter
Copy link
Member

I see this AMP component as also powering app shell capabilities. If the live regions of the AMP document are marked, then the app shell is essentially the document with the regions replaced with placeholders. This can then be cached as the app shell for subsequent launches of the app to then be populated with the regions in the requested URL, which is also either cached or which needs to be fetched from the network.

@westonruter
Copy link
Member

One use case that has come up several times related to seamless page transitions and app shell is the ability for an AMP-first site to provide a persistent audio player (e.g. for a radio station) playing in a fixed bar at the bottom of the page. So I'd like to make sure that the implementation of seamless page transitions accommodates that use case, and that it's not just window dressing for a multi-page application. In other words, it should facilitate turning valid AMP pages into true single-page applications.

@westonruter
Copy link
Member

A library which may provide some inspiration for the API is barba.js.

For example, it is configured by adding certain data attributes to the page which mark the dynamic sections:

<body data-barba="wrapper">
  <!-- put here content that will not change
  between your pages, like <header> or <nav> -->

  <main data-barba="container" data-barba-namespace="home">
    <!-- put here the content you wish to change
    between your pages, like your main content <h1> or <p> -->
  </main>

  <!-- put here content that will not change
  between your pages, like <footer> -->
</body>

It's a similar idea to amp-next-page v1.0 actually.

@stale
Copy link

stale bot commented Jan 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale Inactive for one year or more label Jan 16, 2022
@stale stale bot closed this as completed Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants