diff --git a/src/content/docs/basics/pseudos.mdx b/src/content/docs/basics/pseudos.mdx index 92f769e..cf34c3a 100644 --- a/src/content/docs/basics/pseudos.mdx +++ b/src/content/docs/basics/pseudos.mdx @@ -153,7 +153,7 @@ The View Transition API introduces five types of pseudo-elements: - `::view-transition-old` - `::view-transition-new` -The `::view-transition` pseudo-element, which is rooted at the `` element of the DOM, is the root of all pseudo-elements created by the View Transition API. +The `::view-transition` pseudo-element, which is rooted at the document's documentElement, is the root of all pseudo-elements created by the View Transition API. All these pseudo-elements only exist briefly during the transition effect, making them difficult to spot in the DOM. @@ -168,7 +168,7 @@ inspect(top.document.querySelector("#vtbag-main-frame").contentDocument.querySel ​ ::view-transition // the parent of all groups - ​::view-transition-group(root) // the group of the element + ​::view-transition-group(root) // the group of the document's documentElement ​::view-transition-group(myName) // the group for "view-transition-name: myName" ... ​​…​ @@ -176,7 +176,7 @@ inspect(top.document.querySelector("#vtbag-main-frame").contentDocument.querySel ​​ ``` -Here `root` is the automatically assigned[^root] `view-transition-name` for the `` element (:root) of your document. `myName` is an arbitrary example `view-transition-name`. +Here `root` is the automatically assigned `view-transition-name` for the document's documentElement (:root). `myName` is an arbitrary example `view-transition-name`. ::: @@ -192,14 +192,14 @@ The `::view-transition-new` images are no simple screenshots but _replaced eleme This might be confusing, as the original element is usually hidden behind the `::view-transition` pseudo-element (the “curtain”). Here's the key difference: old images are immutable. For example, if you show the _old image_ of a video player during a view transition, the image is frozen. Replaced elements, however, are _live_. If you display a _new image_ of a video player, the video will continue to play during the transition. -DOM elements without an explicit `view-transition-name` won't generate their own images, with one exception: the document's `:root` element, ``. The View Transition API automatically assigns `view-transition-name: root` to it. You can override this with your own name or **opt out** entirely by assigning the special value `none`: +DOM elements without an explicit `view-transition-name` won't generate their own images, with one exception: the document's `:root` element. The View Transition API automatically assigns `view-transition-name: root` to it. You can override this with your own name or **opt out** entirely by assigning the special value `none`: ```css :root { view-transition-name: none; } ``` -This removes the view transition name from the document's `` element. +This removes the view transition name from the document's `:root` element. ### Groups and Image-Pairs @@ -207,7 +207,7 @@ Because view transition names must be unique[^unique] inside their DOM, there ca ```c ::view-transition // the parent of all groups - ​::view-transition-group(root) // the transition group of the element + ​::view-transition-group(root) // the transition group of the :root element ::view-transition-image-pair(root) // the image pair for the root group ::view-transition-old(root) // with the old image of the root group ::view-transition-new(root) // and the new image of the root group @@ -237,7 +237,7 @@ The `::view-transition-old` pseudo elements are created in a pre-order depth fir The ::view-transition-old pseudo-elements are created during a pre-order depth-first traversal of the old DOM. When an element with a view-transition-name is encountered, its old image is rendered. During this process, other elements with view transition names are effectively ignored, as if their visibility were set to hidden. This ensures that the images have "holes" where other images can be properly placed. -The image of the `` element, if not [opted out](#opt-out), covers the whole viewport. Its view transition group is the first in the list of `::view-transition-group` children of the `::view-transition` pseudo-element. Subsequent groups are added after the root group once their old images have been created. +The image of the `:root` element, if not [opted out](#opt-out), covers the whole viewport. Its view transition group is the first in the list of `::view-transition-group` children of the `::view-transition` pseudo-element. Subsequent groups are added after the root group once their old images have been created.
```d2 width=450 sketch title="Creation of old images" @@ -266,9 +266,9 @@ If no existing group is found, a `new ::view-transition-image-pair` and `::view- ```
-As with the old DOM, the pre-order depth-first traversal of the new DOM typically identifies the `` element as the first to have its image captured. +As with the old DOM, the pre-order depth-first traversal of the new DOM typically identifies the `:root` element as the first to have its image captured. -In a typical setup, where the View Transition API automatically assigns the `root` view transition name to the `` element in both the old and new DOM, the group for the `root` transition name will already exist when the image of the `` element is captured in the new DOM. Thus, the first five lines of the output, [as shown above](#groups-and-image-pairs), are common in most settings. +In a typical setup, where the View Transition API automatically assigns the `root` view transition name to the `:root` element in both the old and new DOM, the group for the `root` transition name will already exist when the image of the `:root` element is captured in the new DOM. Thus, the first five lines of the output, [as shown above](#groups-and-image-pairs), are common in most settings. When examining the `::view-transition-groups` in order, the elements at the start of the list will have at least an old image, while those towards the end will have at least a new image. diff --git a/src/content/docs/basics/styling.mdx b/src/content/docs/basics/styling.mdx index 9a9faa1..ba12e3e 100644 --- a/src/content/docs/basics/styling.mdx +++ b/src/content/docs/basics/styling.mdx @@ -32,16 +32,7 @@ It is not important to have much imagination when choosing names. They can be th At the start of the view transition, the **view transition names have to be unique** in the DOM. You can exempt an element from this uniqueness check by setting its (or one of its parent's) styling to `visibility: hidden` or `display: none`. For those elements, the browser won't generate pseudos. -The browser automatically assigns the view transition name `root` to the `:root` element, i.e. the top-level `` element of the DOM. If you prefer another name, you can override it. If you do not want the `` element to participate in the view transition with own pseudo-elements, you explicitly have to remove the `root` name with either -```css -:root { - view-transition-name: none; -} -``` -or -```html - -``` +The browser automatically assigns the view transition name `root` to the `:root` element, i.e. the top-level `` element for an HTML document. If you prefer another name, you can override it. If you do not want the `` element to participate in the view transition with own pseudo-elements, you explicitly have to remove the `root` name by [overriding it with `none`](/basics/pseudos/#opt-out). Of course view transition names do not need to be static. You can assign them conditionally, e.g. inside a media query or with a selector that checks for a special CSS class further up the DOM. Another interesting way for conditional assignment of view transition names is to let the m [depend on view transition types](/basics/styling/#conditional-view-transitions). diff --git a/src/content/docs/tips/pseudo-smooth-scrolling.mdx b/src/content/docs/tips/pseudo-smooth-scrolling.mdx index 216c2c5..198619a 100644 --- a/src/content/docs/tips/pseudo-smooth-scrolling.mdx +++ b/src/content/docs/tips/pseudo-smooth-scrolling.mdx @@ -61,7 +61,7 @@ There are two ways to avoid the effect. ### Just Animate the Root The pseudo-smooth-scrolling effect only occurs when the `view-transition-name` is applied to an HTML element other than the top-level `` element. The View Transition API [treats the `:root` element differently](https://drafts.csswg.org/css-view-transitions-1/#capture-the-image). The old and new images of the document element are always constrained to the size of the viewport, meaning the default group animation doesn’t transform the position and no scrolling happens at all. -If possible, resist the temptation to apply a view transition name to large content elements. Instead, use the `root` transition group on the `` element to achieve the desired effect. If you fear that your root group now obscures header, footer, and navbar, you can always assign view transition names to those elements, allowing them to enter the view transition layer and [cover portions of the root images](/basics/pseudos/#rendering-pseudo-elements) as needed. +If possible, resist the temptation to apply a view transition name to large content elements. Instead, use the `root` transition group on the document's documentElement to achieve the desired effect. If you fear that your root group now obscures header, footer, and navbar, you can always assign view transition names to those elements, allowing them to enter the view transition layer and [cover portions of the root images](/basics/pseudos/#rendering-pseudo-elements) as needed. ### Make Use of the Cam-Shaft diff --git a/src/pages/demo-explainer/BasicC.mdx b/src/pages/demo-explainer/BasicC.mdx index 74c6df2..b40c620 100644 --- a/src/pages/demo-explainer/BasicC.mdx +++ b/src/pages/demo-explainer/BasicC.mdx @@ -21,7 +21,7 @@ For the styling see the source of this page. ### View Transition specific CSS -The only code to enbale view transitions for this example consists of a single `@view-transition` rule: +The only code to enable view transitions for this example consists of a single `@view-transition` rule: ```css @view-transition { navigation: auto;