8000 [css-view-transitions-2] Syntax for navigation-matching · Issue #8925 · w3c/csswg-drafts · GitHub
[go: up one dir, main page]

Skip to content

[css-view-transitions-2] Syntax for navigation-matching #8925

@noamr

Description

@noamr

Proposing a syntax for matching one or more "navigations" as being the current ones, to be matchable in media-queries (and later other places).

A lot of the issues with view-transitions, especially cross-document, are around using different transitions based on different characteristics of the navigation:
#8784 (different transition for reload)
#8685 (different transition for back/forward)
#8683 (different transition for page type, e.g. home->article vs. articles->article)
#8209 (list<->details)
#8048 (opt-in for cross-document transitions)

These issues circle around some sort of url pattern matching, but adding url patterns to media queries seems verbose and might create duplications.

The proposal here is to use a @ rule that names a navigation-matcher, and then use it in media queries. For example:

@navigation to-article {
   match: urlpattern(/article);
   type: navigation back-forward;
   direction: outgoing;  
}

@media (navigation: to-article) {
   a.article { view-transition: hero };
}

In the spirit of #8677 (keeping MPA/SPA APIs compatible), the concept of navigation-matching here is not specific to MPAs.

A navigation always has an "old" and "new" URL, and a type. The current navigation is updated in the following scenarios:

  • When a document is activated, the previous active document's URL is the old URL and the active document's URL is the new URL.
  • When an a element is clicked, the current URL at the time of clicking is the old URL, and the href is the new URL. This creates a referable point in time for "same-document navigations", which are not a defined term.
  • When popping the state (same-document back/forward), the old document is the one right before the popstate event is fired, and the new one is the new URL.
  • Type is navigation/back-forward/reload, which maps to the existing "navigation timing type" concept

Notes:

  • Exposing previous URLs in this scenarios should adhere by referrer-policy and any other policy. i.e. CSS should only know about the previous cross-origin URL only if that information is also available in other means.
  • Several navigation matchers can match the current navigation at the same time, e.g. with wildcard URL patterns.
  • This makes it possible to customize when cross-document transitions are enabled, e.g.
@auto-view-transitions: same-origin; // bikeshedding the opt-in, see #8048
@media (navigation: to-article) {
@auto-view-transitions: none;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0