Skip to content

Commit 6f9c69f

Browse files
committed
[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. Closes w3c#10334
1 parent aa94f65 commit 6f9c69f

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

css-view-transitions-2/Overview.bs

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ spec:css-view-transitions-1;
3838
text: setup view transition; type: dfn;
3939
text: named view transition pseudo-element; type: dfn;
4040
text: rendering suppression for view transitions; type: dfn;
41+
text: view transition tree; type: dfn;
42+
text: view transition name; type: dfn;
4143
spec:dom; type:dfn; text:document
4244
spec:css22; type:dfn; text:element
4345
spec:selectors-4; type:dfn;
@@ -52,6 +54,7 @@ spec:html
5254
text: has been revealed; type: dfn;
5355
text: render-blocking mechanism; type: dfn;
5456
spec:infra; type:dfn; text:list
57+
spec:css-borders-4; type: property; text:border-radius;
5558
</pre>
5659

5760
<style>
@@ -732,6 +735,95 @@ div.box {
732735
1. Return |viewTransition|.
733736
</div>
734737

738+
# Nested view-transitions # {#nested-view-transitions}
739+
740+
## Overview ## {#nested-overview}
741+
742+
*This section is non-normative.*
743+
744+
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+
735827
# Algorithms # {#algorithms}
736828

737829
## Data structures ## {#cross-doc-data-structures}
@@ -778,6 +870,9 @@ The [=captured element=] struct should contain these fields, in addition to the
778870
<dl>
779871
: <dfn for="captured element">class list</dfn>
780872
:: a [=/list=] of strings, initially empty.
873+
874+
: <dfn for="captured element">containing group</dfn>
875+
:: Null or a string, initially null.
781876
</dl>
782877

783878
## Resolving the ''@view-transition'' rule ## {#vt-rule-algo}
@@ -983,6 +1078,30 @@ When capturing the old or new state for an element, perform the following steps
9831078
Note: This is written in a monkey-patch manner, and will be merged into the algorithm once the L1 spec graduates.
9841079
</div>
9851080

1081+
## Capturing and applying 'view-transition-group' ## {#vt-group-algorithm}
1082+
1083+
<div algorithm="additional capture steps (group)">
1084+
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'.
1087+
</div>
1088+
1089+
<div algorithm="additional pseudo-element setup steps (group)">
1090+
When setting up the transition pseudo-element for a [=captured element=] |capturedElement|, given a |transitionName|:
1091+
1092+
1. If |capturedElement|'s [=containing group=] is not null, then:
1093+
1094+
1. Let |group| be the ''::view-transition-group()'',
1095+
with its [=view transition =name=] set to |transitionName|.
1096+
1097+
1. Let |parentGroup| be the ''::view-transition-group()'',
1098+
with its [=view transition name=] set to |capturedElement|'s [=containing group=].
1099+
1100+
1. Append |group| to |parentGroup|.
1101+
</div>
1102+
1103+
1104+
9861105
<h2 id="priv" class="no-num">Privacy Considerations</h2>
9871106

9881107
This specification introduces no new privacy considerations.

0 commit comments

Comments
 (0)