diff --git a/src/components/TestPage.astro b/src/components/TestPage.astro
index d744823..820d6ae 100644
--- a/src/components/TestPage.astro
+++ b/src/components/TestPage.astro
@@ -32,24 +32,7 @@
return { name: ua, version: "" };
}
- const activation = (act) => {
- copy = {};
- copy.from = {};
- copy.from.url = act?.from?.url;
- copy.from.index = act?.from?.index;
- copy.entry = {};
- copy.entry.url = act?.entry?.url;
- copy.entry.index = act?.entry?.index;
- copy.navigationType = act?.navigationType;
- return copy;
- };
addEventListener("pagereveal", (e) => {
- const d = {};
- d.viewTransition = e?.viewTransition;
- d.activation = activation(
- "navigation" in window ? window.navigation?.activation : undefined
- );
- sessionStorage.setItem("vtbag-pagereveal", JSON.stringify(d));
e.viewTransition?.ready.then(() => {
const as = document.getAnimations();
as.forEach((a) => {
@@ -60,43 +43,42 @@
});
addEventListener("pageswap", (e) => {
- const d = {};
- d.viewTransition = e?.viewTransition;
- d.activation = activation(e?.activation);
- sessionStorage.setItem("vtbag-pageswap", JSON.stringify(d));
+ sessionStorage.removeItem("vtbag-pageswap-idx");
+ (e.activation?.entry?.index ?? -1 !== -1) &&
+ sessionStorage.setItem("vtbag-pageswap-idx", "x");
});
addEventListener("load", () => {
- setTimeout(() => {
- if (!new URL(location, location.href).searchParams.has("pagereveal")) {
- location.href = "/basics/test-page/?pagereveal";
+ setTimeout(async () => {
+ if (!sessionStorage.getItem("vtbag-test-page")) {
+ sessionStorage.setItem("vtbag-test-page", "x");
+ location.href = "/basics/test-page/";
} else {
- const reveal = JSON.parse(sessionStorage.getItem("vtbag-pagereveal"));
- const swap = JSON.parse(sessionStorage.getItem("vtbag-pageswap"));
- reveal && document.documentElement.setAttribute("cdvt", "");
- reveal?.viewTransition &&
- document.documentElement.setAttribute("prvt", "");
- reveal?.activation &&
- document.documentElement.setAttribute("ract", "");
- swap?.viewTransition &&
- document.documentElement.setAttribute("psvt", "");
- swap?.activation && document.documentElement.setAttribute("sact", "");
- ((swap?.activation?.entry?.index ?? -1) !== -1 ||
- (swap?.activation?.from?.index ?? -1) !== -1) &&
- document.documentElement.setAttribute("idx", "");
- "startViewTransition" in document &&
+ sessionStorage.removeItem("vtbag-test-page");
+ if (document.startViewTransition) {
+ let matchElement = true;
+ await document.startViewTransition().ready;
+ document.getAnimations().forEach((a) => {
+ if (a.animationName === "no-match-element") matchElement = false;
+ });
document.documentElement.setAttribute("sdvt", "");
- "navigation" in window &&
- document.documentElement.setAttribute("nav", "");
+ matchElement && document.documentElement.setAttribute("vtnme", "");
+ }
+ "onpageswap" in window &&
+ document.documentElement.setAttribute("cdvt", "");
+ sessionStorage.getItem("vtbag-pageswap-idx") &&
+ document.documentElement.setAttribute("idx", "");
CSS.supports("view-transition-class", "mine") &&
document.documentElement.setAttribute("vtc", "");
- CSS.supports("view-transition-name", "auto") &&
- document.documentElement.setAttribute("vtna", "");
CSS.supports("view-transition-group", "g") &&
document.documentElement.setAttribute("vtg", "");
document.documentElement.getAttribute("_vtgc") &&
document.documentElement.setAttribute("vtgc", "");
+ document.documentElement.getAttribute("_vtnme") &&
+ document.documentElement.setAttribute("vtnme", "");
document.body.startViewTransition &&
document.documentElement.setAttribute("svt", "");
+ "navigation" in window &&
+ document.documentElement.setAttribute("nav", "");
"prerendering" in document &&
document.documentElement.setAttribute("spec", "");
@@ -114,12 +96,20 @@
diff --git a/src/content/docs/basics/levels.mdx b/src/content/docs/basics/levels.mdx
index 70f0eee..d8c1143 100644
--- a/src/content/docs/basics/levels.mdx
+++ b/src/content/docs/basics/levels.mdx
@@ -44,7 +44,7 @@ Part two indeed adds extensions for cross-document view transitions, but also fe
### Extensions for Both, Same- and Cross-Document
* The [`view-transition-class`](/basics/styling/#with-classes) property and selector syntax to address multiple pseudo-elements with a single selector.
* [View transition types](/basics/styling/#with-types) being part of the ViewTransition object, the `startViewTransition()` signature, and the `@view-transition{ }` at-rule; as well as matching pseudo-class selector `:active-view-transition-type()` and the type-less `:active-view-transition`.
-* [Generated view transition names](/basics/pseudos/#auto-generated-names-auto-and-match-element) with `view-transition-name: auto` and `view-transition-name: match-element`.
+* [Generated view transition names](/basics/pseudos/#auto-generated-names-match-element) with `view-transition-name: auto` and `view-transition-name: match-element`.
* [Nested view transition groups](/basics/pseudos/#nested-view-transition-groups) with the `::view-transition-group-children()` pseudo element.
## Future extensions
diff --git a/src/content/docs/basics/pseudos.mdx b/src/content/docs/basics/pseudos.mdx
index 43e9b10..3529027 100644
--- a/src/content/docs/basics/pseudos.mdx
+++ b/src/content/docs/basics/pseudos.mdx
@@ -167,7 +167,7 @@ At the start of the view transition, the **view transition names have to be uniq
There are two exceptions:
- The API ignores the `view-transition-name` of a fragmented element, i.e. an element that consists of two or more boxes, like an inline element that spans two lines.
-- The API ignores the `view-transition-name` of an element if that element is not rendered, like the `
`, or if it is skipped. For instance, you can use the same `view-transition-name` multiple times within the same DOM, provided that all but one instance have their `display` CSS property set to `none`. Looking for an example? This technique is utilized in the intra-document [image morph examples](/basics/examples/#image-morph-examples) on this site. This trick also works with an ancestor with `content-visibility: hidden` but not with a simple `visibility: hidden` directly on the element.
+- The API ignores the `view-transition-name` of an element if that element is not rendered, like the ``, or if it is skipped. For instance, you can use the same `view-transition-name` multiple times within the same DOM, provided that all but one instance have their `display` CSS property set to `none`. This can also be done by setting an HTML element's hidden attribute or property. Looking for an example? This technique is utilized in the intra-document [image morph examples](/basics/examples/#image-morph-examples) on this site. This trick also works with an ancestor with `content-visibility: hidden` but not with a simple `visibility: hidden` directly on the element.
The static user agent stylesheet provides one default name for the document, called `root`.
@@ -183,6 +183,9 @@ This default defines an animation for the current viewport. If you want to anima
view-transition-name: none;
}
```
+The special value `none` removes a potentially set view transition name.
+
+Other special names are [`match-element`](#auto-generated-names-match-element) and `auto`, and all names beginning with `-ua-`.
### Escaping
Do not quote the names. They are not strings but [custom-ident](https://developer.mozilla.org/de/docs/Web/CSS/custom-ident) values. Ensure proper escaping of special characters. The simplest, most portable approach is to just use upper and lower case letters from A to Z, digits from 0 to 9, an underscore `_` or a hyphen `-` character. But don't start the name with a digit. While all other characters with a code < 128 need to be escaped, codes > 127 like 😄 seem to work just fine in view transition names. In browsers, you can use `CSS.escape()` to properly escape strings as custom identifiers.
@@ -190,30 +193,63 @@ Do not quote the names. They are not strings but [custom-ident](https://develope
It is not important to have much imagination when choosing names. They can be the similar to the `id` of an element or name of a unique tag like `body` or `footer`.
-### Auto-Generated Names: auto and match-element
-The opposite problem to view transition names not being unique is that elements need to have _any_ `view-transition-name` assigned in order to trigger a group or morph animation. Often, the actual value doesn't matter. What's important is simply having a value defined. For large numbers of elements, doing this manually can be cumbersome. You can automate it with JavaScript, as with the headings on this site or in [this demo](/tips/auto-names/). However, it is also possible to do this with only CSS by using the `auto` value, no JavaScript needed.
+### Auto-Generated Names: match-element
+The opposite problem to view transition names not being unique is that elements need to have _any_ `view-transition-name` assigned in order to trigger a group or morph animation. Often, the actual value doesn't matter. What's important is simply having a value defined as it acts as a marker for elements for which the API should generate view transition groups. For large numbers of elements, doing this manually can be cumbersome. You can automate it with JavaScript, as with the headings on this site or in [this demo](/tips/auto-names/).
+
+However, it is also possible to do this with only CSS by using the `match-element` value, no JavaScript needed.
```css
-.tile {
- view-transition-name: auto;
-}
.card {
view-transition-name: match-element;
}
```
-[Check if your current browser already supports it](/basics/test-page/).
-
-Both, `auto` and `match-element`, assign a generated name that is bound to the DOM element.
-Those names typically look like `-ua-auto-....`.
+Using `match-element` assigns a generated name that is bound to the DOM element.
+Those names typically look like `-ua-....` with some random suffix.
Two different elements are always assigned different values.
When you set the view transition name multiple times for the same element that way, it will always get the same name.
-Safari, first checks for an existing `id` attribute, and instead copies its value if it exists. Chromium browsers don't.
+How could you style your pseudo-elements, if they have an unknown random name? The general approach here is to also assign a view transition class.
+```css
+.card {
+ view-transition-name: match-element;
+ view-transition-class: card;
+}
+```
+The class name does not need to be unique across elements. Then [use the view transition class name](/basics/styling/#with-classes) in your style rules.
+
+This works fine for **same-document** view transitions on supporting browsers.
+For **cross-document** view transitions, generated names for the two document should never be the same. Therefore groups created from `match-element` in cross-document view transitions wi ll always have image-pairs with a single old or new image, only.
+
+:::caution
+That is, if they are created. Safari seems to handle `match-element` like `none` in cross-document view transitions for elements that do not define an `id`.
+:::
+
+Until it gets broader, convergent support in browsers, **I would not recommend `match-element`** for cross-document view transitions. There are [alternatives](/tips/auto-names/#how-to-assign-names-automatically) that work cross-browser and also for cross-document navigation.
+
+### Auto-Generated Names: auto
+
+_`view-transition-name: auto` is a bit of a mess right now. Use with caution._
+
+Browser also defined `auto` as a special value for `view-transition-name`, but its semantics are not consistent across browsers and its specification is work in progress. Do not use it (yet).
+
+```css
+selector {
+ view-transition-name: auto;
+}
+```
+This is similar to `match-element` but it also takes the `id` property of an HTML element into account: If the `id` property is set, `auto` generates the same view transition name for all elements with that `id`, independent of the document that element belongs to.
+Different ids generate different view transition names. The generated name has to start with `-ua-`.
+
+Different browsers and browser versions show divergent behavior. Safari used to directly use the `id` value as view transition name. Current versions use `-ua-id-`, where `` is the element's `id` value. Chrome uses random values similar to those generated for `match-element`.
+
+:::caution
+Like with `match-element`, Safari seem to not generate random names for cross-document view transitions enabled with `@view-transition{navigation: auto}`. Only for view transitions started by `startViewTransition()`.
+:::
-With cross-document view transitions, auto-generated names of the two documents will never be the same, [not even when `id` attributes would match](https://drafts.csswg.org/css-view-transitions-2/#additions-to-vt-name).
+### Using id as View Transition Name
-`match-element` will always assign a random name, no matter wether the `id` attribute is set or not. On Chromium browsers, `auto` and `match-element` seem to be the same thing.
+_Not available across browsers, yet._
On Chromium browsers you would use the following incantation to use the id attribute as an view transition name:
```css
@@ -224,10 +260,9 @@ Here `type()` is necessary to make the id a custom-ident, and `non
Fun fact: The following works in Chrome like the original Safari version of `auto`: Use the `id` attribute if defined, otherwise make up some name.
```css
-view-transition-name: attr(id type(), auto);
+view-transition-name: attr(id type(), match-element);
```
-I would not recommend `auto` for cross-document view transitions. There are [alternatives](/tips/auto-names/#how-to-assign-names-automatically) that work cross-browser and also for cross-document navigation.
diff --git a/src/content/docs/basics/styling.mdx b/src/content/docs/basics/styling.mdx
index 03dd5c3..aade2db 100644
--- a/src/content/docs/basics/styling.mdx
+++ b/src/content/docs/basics/styling.mdx
@@ -139,6 +139,11 @@ The typical cross-fade effect of view transitions is implemented by animations d
animation-duration: inherit;
animation-delay: inherit;
animation-fill-mode: inherit;
+ /* newly added */
+ animation-timing-function: inherit;
+ animation-iteration-count: inherit;
+ animation-direction: inherit;
+ animation-play-state: inherit;
}
::view-transition-old(x) {
animation-name: -ua-view-transition-fade-out, -ua-mix-blend-mode-plus-lighter
diff --git a/src/content/docs/basics/test-page.mdx b/src/content/docs/basics/test-page.mdx
index d1a6be0..d15d34b 100644
--- a/src/content/docs/basics/test-page.mdx
+++ b/src/content/docs/basics/test-page.mdx
@@ -18,17 +18,18 @@ This page shows whether your current browser has nativ
| ------------------------------------------------------------------------------------------------------------ | ----------------- |
| [Same-document view transitions](https://drafts.csswg.org/css-view-transitions-1) | |
| [Cross-document view transitions](https://drafts.csswg.org/css-view-transitions-2) | |
-| [Navigation API](https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API) | |
| [PageSwapEvent.activation.\*.index](https://drafts.csswg.org/css-view-transitions-2/#old-doc-event) | |
-| [view-transition-class](https://drafts.csswg.org/css-view-transitions-2/#view-transition-class-prop) | |
-| [view-transition-name: auto](https://drafts.csswg.org/css-view-transitions-2/#additions-to-vt-name) | |
+| [view-transition-class](https://drafts.csswg.org/css-view-transitions-2/#view-transition-class-prop) | |
+| [view-transition-name: match-element](https://drafts.csswg.org/css-view-transitions-2/#additions-to-vt-name) | |
| [Nested view transition groups](https://drafts.csswg.org/css-view-transitions-2/#view-transition-group-prop) | |
| [View transition group children](https://drafts.csswg.org/css-view-transitions-2/#view-transition-group-children-pseudo) | |
| [Scoped view transitions](https://github.com/WICG/view-transitions/blob/main/scoped-transitions.md) | |
+| [Navigation API](https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API) | |
| [Speculation Rules](https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API) | |
-
+
+
In current Chrome versions (>= 134), `nested view transition groups` and `view-transition-name: auto` are available when you enable "Experimental Web Platform features" on `chrome://flags`. `scoped view transitions` are supported in versions >= 136 (canary).
@@ -40,9 +41,7 @@ For browser compatibility data regarding the View Transition API see [the mdn pa
#sdvt,
#cdvt,
#nav,
- #psvt,
- #prvt,
- #vtna,
+ #vtnme,
#vtc,
#vtg,
#vtgc,
@@ -57,12 +56,10 @@ For browser compatibility data regarding the View Transition API see [the mdn pa
:root[sdvt] #sdvt,
:root[cdvt] #cdvt,
:root[nav] #nav,
- :root[svt] #psvt,
- :root[rvt] #prvt,
:root[vtc] #vtc,
:root[vtg] #vtg,
:root[vtgc] #vtgc,
- :root[vtna] #vtna,
+ :root[vtnme] #vtnme,
:root[idx] #idx,
:root[svt] #svt,
:root[spec] #spec
diff --git a/src/content/docs/fwvt/playing.mdx b/src/content/docs/fwvt/playing.mdx
index 7749175..0a27e78 100644
--- a/src/content/docs/fwvt/playing.mdx
+++ b/src/content/docs/fwvt/playing.mdx
@@ -571,7 +571,7 @@ If the active view transition type caught your interest, this way of guarding us
If you wondered why this demo doesn't use `view-transition-name: auto` or `view-transition-name: match-element`, here is the answer:
-[Auto-generated](/basics/pseudos/#auto-generated-names-auto-and-match-element) view transition names are fine if you do not need to address individual elements. You can still address _all_ elements using view transition classes. But because the auto-assigned name is the APIs little secret, you do not know it and thus can't use it to address a particular element.
+[Auto-generated](/basics/pseudos/#auto-generated-names-match-element) view transition names are fine if you do not need to address individual elements. You can still address _all_ elements using view transition classes. But because the auto-assigned name is the APIs little secret, you do not know it and thus can't use it to address a particular element.
For staggered animations we assign individual delays to the disks and for this we need to know the name of the pseudo-element. If you were counting on `sibling-index()` to make things easier in combination with the `.disk` view transition class, sorry to disappoint: tree-counting functions only work on real DOM elements, not on pseudo-elements.
diff --git a/src/content/docs/tips/auto-names.mdx b/src/content/docs/tips/auto-names.mdx
index 744aa79..2fa3650 100644
--- a/src/content/docs/tips/auto-names.mdx
+++ b/src/content/docs/tips/auto-names.mdx
@@ -41,47 +41,47 @@ In reality, you don't want to select each element individually. Instead, you wan
## How to Assign Names Automatically?
Here are your options right now:
-* For same-document view transitions, only: generate [dynamic identifiers](/basics/pseudos/#auto-generated-names-auto-and-match-element) with `match-element` (or `auto`): \
-`selector { view-transition-name: match-element; } /* or auto */`
-* _Not yet baseline: Copy an existing unique attribute like `id`: \
-`selector { view-transition-name: attr(id type()); }`
+* Currently only feasible for same-document view transitions: generate dynamic identifiers with [match-element](/basics/pseudos/#auto-generated-names-match-element)
+
+* In rare cases also for cross-document view transitions: generate dynamic identifiers with [auto](/basics/pseudos/#auto-generated-names-auto) for elements with `id` properties.
+
+* [Copy an existing unique attribute](/basics/pseudos/#auto-generated-names-match-element) like `id`
* In JavaScript, do something like \
`querySelectorAll("selector").forEach(e => e.style.viewTransitionName = ...)`
-* Use a script like [`declarative-names`](/tools/utensil-drawer/#declarative-names) script \
+* Use a script like the [`declarative-names`](/tools/utensil-drawer/#declarative-names) script \
``
-I wouldn't recommend the first two approaches just yet, as they are still a bit experimental for cross-document view transitions and don't work reliably across all browsers. But I'm curious and looking forward to what the future has in store.
-### Special View Transition Names
+I would **not recommend the first three** approaches just yet, as of today, they don't work reliably across all browsers. But I'm curious and looking forward to what the future has in store.
+
+### Auto Generated Names
-Assigning `auto` as a view transition name dynamically generates unique names.
-Safari supports this since 18.2, in Chrome it is hidden behind a flag, in Edge it is not supported.
-Where it is supported, it works for same-document view transitions. Other than [defined in the specification](https://drafts.csswg.org/css-view-transitions-2/#additions-to-vt-name) it does not or only partly work for cross-document view transitions.
+Assigning `match-element` or `auto` as a view transition name dynamically generates unique names.
+Where it is supported, it works for same-document view transitions.
-Safari generates rather short names, but only for `startViewTransition()`, and not for cross-document view transitions.
+Safari generates rather short names.
```cs
-ua-auto-2235
-ua-auto-2236
-ua-auto-2237
...
```
-Chrome's dynamically generated names at least appear as though they could technically distinguish the owner documents of the old and new page elements during cross-document transitions. However, it only generates old images for `auto` on cross-document view transitions.
+Chrome's dynamically generated names can technically distinguish the owner documents of the old and new page elements during cross-document transitions.
```cs
--ua-auto-F5E19860A59EF9D0C4AAFAA1378C6862-380
--ua-auto-F5E19860A59EF9D0C4AAFAA1378C6862-381
--ua-auto-F5E19860A59EF9D0C4AAFAA1378C6862-382
+-ua-auto-F5E19860A59EF9D0C4AAFAA1378C6862-63044
+-ua-auto-F5E19860A59EF9D0C4AAFAA1378C6862-63051
+-ua-auto-F5E19860A59EF9D0C4AAFAA1378C6862-63058
...
```
-Setting the name to `auto` does not always generate those fancy dynamic names. If the element has an `id`-attribute, its value is used as the view transition name instead. This works fine in Safari but not in Chrome.
+Some Chrome versions conceal the random value by mapping it back to `match-element` on some interfaces. But that might soon change again.
-Chrome and Safari also support `match-element`, which works like `auto` but always generates a dynamic name, even when an `id` attribute is present.
### Using attr() For Names
-Chrome offers `view-transition-name: attr(id type())` as an alternative to `view-transition-name: auto`.
-Currently, this typed `attr()` function is _only available in Chrome_. When used with the `id` attribute, it behaves like the `auto` view transitions name when `id` is set.
+Chrome offers [`view-transition-name: attr(id type())`](/basics/pseudos/#auto-generated-names-match-element) as an alternative way to set view transition names.
+Currently, this typed `attr()` function is _only available in Chrome_.
You might wonder why copying another attribute's value counts as a solution here. After all, you only get automatic view transition names if you have already manually set all those `id` attributes. Well, yes. At least it is less to type.
@@ -99,7 +99,7 @@ ul li:nth-child(even) {
After everything we've covered so far: If you want a solution that reliably works across browsers and can also be used for cross-document view transitions, it seems you're better off doing it yourself. Using `document.querySelectorAll()` lets you take advantage of arbitrary CSS selectors, as seen in the previous section. Plus, you have full control over the names you want to generate and assign.
-Instead of building this functionality from scratch, you can use the declarative-names script from the Utensil Drawer. It also supports CSS selectors and lets you choose the names to use. Plus, you can decide whether to override existing names or keep them and even assign names randomly, creating a randomization effect like in the introductory demo on this page.
+Instead of building this functionality from scratch, you can use the [declarative-names script](/tools/utensil-drawer/#declarative-names) from the Utensil Drawer. It also supports CSS selectors and lets you choose the names to use. Plus, you can decide whether to override existing names or keep them and even assign names randomly, creating a randomization effect like in the introductory demo on this page.
Fun fact: The introductory demo does _not_ use the `declarative-names` script. Honestly, as already [observed](#:~:text=If%20you%E2%80%99re%20generating%20HTML%20from%20data%2C%20you%20can%20also%20generate%20view%20transition%20names%20with%20minimal%20extra%20work.), dynamically adding view transition names is hardly extra work if you're already generating the HTML with JavaScript.
diff --git a/src/styles/sidebar.css b/src/styles/sidebar.css
index b732841..f21c650 100644
--- a/src/styles/sidebar.css
+++ b/src/styles/sidebar.css
@@ -8,7 +8,6 @@ li :has(> a[aria-current="page"]) {
li a[aria-current="page"] {
background-color: transparent;
border-radius: 0;
- view-transition-name: current-page;
&:hover {
border-radius: 0;
background-color: transparent;
@@ -18,9 +17,15 @@ li a[aria-current="page"] {
content: "⭐";
margin-left: 0.5em;
position: absolute;
+ }
+}
+:active-view-transition-type(forward, backward) li a[aria-current="page"] {
+ view-transition-name: current-page;
+ &:after {
view-transition-name: current-page-star;
}
}
+
::view-transition-old(current-page),
::view-transition-new(current-page) {
height: auto;
@@ -37,7 +42,6 @@ li a[aria-current="page"] {
}
}
-
@media (prefers-reduced-motion: no-preference) {
:root {
interpolate-size: allow-keywords;