You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[css-view-transitions-2] Initial spec for nested view transitions
This specifies the new 'view-transition-group' CSS property and how it used,
with some overview and an initial example.
Based on [this resolution](w3c#10334 (comment)).
There are still a lot of open issues but we will open them separately to avoid inflating the initial issue.
Closesw3c#10334
By default, setting `view-transition-name` on multiple elements generates a flat [=view transition tree=], where all the ''::view-transition-group()'' pseudo-elements are children of the ''::view-transition'' pseudo-element.
745
+
This is sufficient for many simple use-cases, but there are some styling use-cases that cannot be achieved with a flat tree.
746
+
The most prominent use-case is clipping: with a flat tree, all pseudo-elements are clipped to the root element, so clipping elements in the normal tree would lose their clipping during the view-transition, resulting in a broken visual effect.
747
+
The effects that have can have an unexpected visual effect in a flat tree:
748
+
* Clipping ('overflow', 'clip-path', 'border-radius'): clipping affects the children of the element.
749
+
* 'opacity', 'mask-image'' and 'filter': These effects that are designed to work on a fully rasterized image of a tree, rather than on each item individually.
750
+
* 3D transforms ('transform-style', 'transform', 'perspective'): to display the full range of 3D transform animations, some hierarchy needs to be kept.
751
+
752
+
To enable these use case, this specification introduces the concept of nesting view-transition pseudo-elements. By using the 'view-transition-group' CSS property,
753
+
the author can assign a "parent group" for a generated ''::view-transition-group()'' pseudo-element, creating a hierarchy in the view-transition [=view transition tree=].
754
+
755
+
## Examples ## {#nested-vt-example}
756
+
757
+
<div class="example">
758
+
This example creates a transition where the [=view transition tree=] is nested instead of flat:
759
+
760
+
```html
761
+
<section class="container">
762
+
<article>Content</article>
763
+
</section>
764
+
```
765
+
766
+
```css
767
+
.container {
768
+
view-transition-name: container;
769
+
}
770
+
771
+
.container,
772
+
::view-transition-group(container) {
773
+
clip-path: circle();
774
+
}
775
+
776
+
article {
777
+
view-transition-name: article;
778
+
view-transition-group: section;
779
+
}
780
+
```
781
+
782
+
By applying the ''clip-path'' to both the containing element and its generated pseudo-element, we preserve the clip during the transition,
783
+
and by applying ''view-transition-group'' to the internal element referencing the container, we make the tree "nested" in a way that would apply this clipping.
784
+
</main>
785
+
786
+
## The 'view-transition-group' property ## {#view-transition-group-prop}
787
+
788
+
<pre class=propdef>
789
+
Name: view-transition-group
790
+
Value: normal | contain | nearest | <<custom-ident>>
791
+
Initial: normal
792
+
Inherited: no
793
+
Percentages: n/a
794
+
Computed Value: as specified
795
+
Animation type: discrete
796
+
</pre>
797
+
798
+
The 'view-transition-group' property can be used in conjuction with 'view-transition-name' to generate a hierarchy of [=named view transition pseudo-element=].
799
+
800
+
The [=used value=] for 'view-transition-group' resolves to a 'view-transition-name' in its ancestor chain, or to ''view-transition-name/none''. When generating the [=named view transition pseudo-element=], the ''::view-transition-group()'' with that name
801
+
would be the parent of the ''::view-transition-group()'' generated for this element's 'view-transition-name'.
802
+
803
+
When the [=computed value=] of 'view-transition-name' for an element is ''view-transition-name/none'', its 'view-transition-group'[=used value=] is always resolved to ''view-transition-name/none'' as well.
804
+
805
+
<dl dfn-type=value dfn-for=view-transition-group>
806
+
: <dfn>normal</dfn>
807
+
:: The '':view-transition-group()'' generated by this element's 'view-transition-name' should be a child of the ''::view-transition'' pseudo-element,
808
+
or of the nearest ancestor with a 'view-transition-group'[=computed value=] of ''view-transition-group/contain''.
809
+
810
+
: <dfn>nearest</dfn>
811
+
:: The '':view-transition-group()'' generated by this element's 'view-transition-name' should be a child of the ''::view-transition-group()'' pseudo-element
812
+
generated by the nearest ancestor with a 'view-transition-name'.
813
+
814
+
: <dfn>contain</dfn>
815
+
:: This is equivalent to ''view-transition-group/normal'', except descendants with a [=computed value=] of ''view-transition-group/normal'' resolve this element's 'view-transition-name'.
816
+
817
+
: <dfn><<custom-ident>></dfn>
818
+
:: The '':view-transition-group()'' generated by this element's 'view-transition-name' should be a child of the ''::view-transition-group()'' pseudo-element
819
+
that matches the given <<custom-ident>>.
820
+
</dl>
821
+
822
+
## Changes to '':view-transition-group()'' ## {#pseudo-element-hierarchy-nested}
823
+
824
+
When the view [=view transition tree=] is generated, every generated ''::view-transition-group()'' becomes a child of an existing ''::view-transition-group()'' with the same name as its generating element's 'view-transition-group'.
825
+
826
+
735
827
# Algorithms # {#algorithms}
736
828
737
829
## Data structures ## {#cross-doc-data-structures}
@@ -778,6 +870,9 @@ The [=captured element=] struct should contain these fields, in addition to the
When capturing the old or new state for an element, perform the following steps given a [=captured element=] |capturedElement| and an [=element=] |element|:
1085
+
1086
+
1. Set |capturedElement|'s [=captured element/containing group=] to the [=used value=] of |element|'s 'view-transition-group'.
0 commit comments