Re: [csswg-drafts] [css-view-transitions-2] Declarative opt-in for cross-document navigations (#8048)

> > Option 1 implies that transitions will be enabled for reloads by default.
> 
> You mean `cross-document-same-origin-navigation` implies that? What if that explicitly excluded reloads? Then we can add a `reload` keyword to `transition-trigger`. A separate `reload` descriptor doesn't seem useful as reloads are meant to be _a type of_ transition trigger. And some combinations of `transition-trigger` and `reload` like `transition-trigger: none; reload: allow;` don't make much sense.
> 
> So the whole syntax would then look like this:
> 
> ```css
> @view-transition {
>   transition-trigger: [ same-document-navigation || cross-document-same-origin-navigation || same-site-navigation || script || reload ] | none;

reload is mutually exclusive from cross-document vs. same-document. E.g. you can have a same-document reload with the navigation API.

I see a navigation as divided into 3:
- the URLs (same-origin vs. cross-origin, and URL patterns)
- The type (push, replace, reload, traverse, as defined [here](https://html.spec.whatwg.org/multipage/nav-history-apis.html#navigationtype)
- Mechanism (cross-document / navigation API), equivalent to `is cross document` in the spec.

The way I see it, the first two might affect which transition is triggered and not just whether it is triggered, while the last one shouldn't. e.g. you probably don't want a different transition based on whether this was a same-document or a cross-document navigation: only based on the type and origin of the navigation.

So to enable reloads in the future I see things this way: we would have a pseudo-class to the rule which qualifies the navigation (type+origin), but does not qualify based on mechanism:

```css
/* UA stylesheet */
@view-transitions :reload {
  navigation-trigger: none;
}

@view-transitions {
  navigation-trigger: none;
}

/* user stylesheet: this would enable cross-document VT but *not* reload, due to specificity  */
@view-transitions {
  navigation-trigger: cross-document;
}

/* user stylesheet: this would enable cross-document VT on reload  */
@view-transitions :reload {
  navigation-trigger: cross-document;
}
```
This of course needs more work but the general idea is that whatever qualifies the navigation and can affect which transition is triggered and not just whether it's triggered, goes outside the brackets and not into the `navigation-trigger` rule. Happy to hear alternatives.

-- 
GitHub Notification of comment by noamr
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8048#issuecomment-1670850775 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 9 August 2023 07:56:47 UTC