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] Define the view-transition-group-children pseudo element (#12277)
* [css-view-transitions-2] Define the view-transition-group-children pseudo
This new pseudo is an ancestor to the other nested groups, and is positioned
after the group's view-transition-image-pair which contains the group's contents.
Resolution:
#11926 (comment)Closes#11926
text: global view transition user agent style sheet; type: dfn;
49
50
spec:dom; type:dfn; text:document
50
51
spec:css22; type:dfn; text:element
51
52
spec:selectors-4; type:dfn;
@@ -860,7 +861,7 @@ This example creates a transition where the [=view transition tree=] is nested i
860
861
}
861
862
862
863
.container,
863
-
::view-transition-group(container) {
864
+
::view-transition-group-children(container) {
864
865
clip-path: circle();
865
866
}
866
867
@@ -870,7 +871,22 @@ article {
870
871
}
871
872
```
872
873
873
-
By applying the ''clip-path'' to both the containing element and its generated pseudo-element, we preserve the clip during the transition,
874
+
The pseudo-element tree for this would be as follows:
875
+
```
876
+
::view-transition
877
+
├─ ::view-transition-group(container)
878
+
│ ├─ ::view-transition-image-pair(container)
879
+
│ | ├─ ::view-transition-old(container)
880
+
│ | └─ ::view-transition-new(container)
881
+
│ └─ ::view-transition-group-children(container)
882
+
│ ├─ ::view-transition-group(article)
883
+
│ | ├─ ::view-transition-old(article)
884
+
│ | └─ ::view-transition-new(article)
885
+
│ └─ ...other nested groups...
886
+
└─ …other groups…
887
+
```
888
+
889
+
By applying the ''clip-path'' to both the containing element and its generated ''::view-transition-group-children()'' pseudo-element, we preserve the clip during the transition,
874
890
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.
875
891
</main>
876
892
@@ -889,7 +905,34 @@ and by applying ''view-transition-group'' to the internal element referencing th
889
905
The 'view-transition-group' property can be used in conjuction with 'view-transition-name' to generate a hierarchy of [=named view transition pseudo-element=].
890
906
891
907
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
892
-
would be the parent of the ''::view-transition-group()'' generated for this element's 'view-transition-name'.
908
+
would create a ''::view-transition-group-children()'' pseudo-element, which would be the parent of the ''::view-transition-group()'' generated for this element's 'view-transition-name'.
909
+
910
+
### View Transition Tree Root: the ''::view-transition-group-children'' pseudo-element ### {#view-transition-group-children-pseudo}
911
+
912
+
The <dfn>::view-transition-group-children()</dfn>[=pseudo-element=]
913
+
is a [=named view transition pseudo-element=]
914
+
that represents a matching named [=view transition=] capture.
915
+
A ''::view-transition-group-children()''[=pseudo-element=]
916
+
is generated based on the 'view-transition-group' property,
917
+
as a [=tree/child=] of the corresponding ''::view-transition-group()''[=pseudo-element=],
918
+
and contains one or more ''::view-transition-group()'' elements, corresponding to the nested groups.
919
+
See the [=used group name=] and related algorithms.
920
+
921
+
The ''::view-transition-group-children()''[=pseudo-element=] is positioned after its sibling ''view-transition-image-pair()''.
922
+
It is used to control effects like clipping or masking of nested children.
923
+
924
+
## User Agent Stylesheet # {#ua-styles}
925
+
926
+
This specification extends the [=global view transition user agent style sheet=] by adding the following rule:
927
+
928
+
```css
929
+
:root::view-transition-group-children(*) {
930
+
position: absolute;
931
+
inset: 0;
932
+
border-style: solid;
933
+
border-color: transparent;
934
+
}
935
+
```
893
936
894
937
# Algorithms # {#algorithms}
895
938
@@ -953,7 +996,10 @@ The [=captured element=] struct should contain these fields, in addition to the
953
996
:: Null or a string, initially null.
954
997
955
998
: <dfn for="captured element">transform from snapshot containing block</dfn>
:: 'border-width'[=used value=] (top, right, bottom and left pixel values) or null, initially null.
957
1003
</dl>
958
1004
959
1005
## Resolving the ''@view-transition'' rule ## {#vt-rule-algo}
@@ -1219,6 +1265,8 @@ To resolve the <dfn>used group name</dfn> of an {{Element}} |element|, perform t
1219
1265
When [[css-view-transitions-1#capture-old-state-algorithm|capturing the old state for an element]], perform the following steps given a [=captured element=] |capturedElement|, a {{ViewTransition}} |transition|, and an [=element=] |element|:
1220
1266
1221
1267
1. Set |capturedElement|'s [=captured element/containing group name=] to |element|'s [=used group name=] given |transition|.
1268
+
1269
+
1. Set |capturedElement|'s [=captured element/old border width=] to |element|'s [=used value|used=]'border-width'.
1222
1270
</div>
1223
1271
1224
1272
### Compute the new 'view-transition-group' ### {#vt-group-capture-new}
@@ -1233,19 +1281,23 @@ When [[css-view-transitions-1#capture-new-state-algorithm|capturing the new stat
1233
1281
When [[css-view-transitions-1#setup-transition-pseudo-elements-algorithm|setting up the transition pseudo-element]] for a [=captured element=] |capturedElement|, given a |transitionName| and a |transition|:
1234
1282
1235
1283
1. Let |containingGroupName| be |capturedElement|'s [=containing group name=].
1236
-
1. If |containingGroupName| is not null, then:
1237
1284
1238
-
1. Let |groupContainerElement| be |transition|'s [=ViewTransition/named elements=][|containingGroupName|].
1285
+
1. If |containingGroupName| is null, return.
1286
+
1287
+
1. Let |groupContainerElement| be |transition|'s [=ViewTransition/named elements=][|containingGroupName|].
1288
+
1289
+
1. Let |group| be the ''::view-transition-group()'',
1290
+
whose [=view transition name=] is set to |transitionName|.
1239
1291
1240
-
1. Let |group| be the ''::view-transition-group()'',
1241
-
whose [=view transition name=] is set to |transitionName|.
1292
+
1. Let |childrenContainerGroup| be the ''::view-transition-group-children()'' whose [=view transition name=] is set to |containingGroupName|.
1242
1293
1243
-
1. Let |parentGroup| be the ''::view-transition-group()'',
1244
-
whose [=view transition name=] is set to |containingGroupName|.
1294
+
1. If |childrenContainerGroup| does not exist:
1295
+
Generate it and append to the ''::view-transition-group()'',
1296
+
whose [=view transition name=] is set to |containingGroupName|.
1245
1297
1246
-
1. Append |group| to |parentGroup|.
1298
+
1. Append |group| to |childrenContainerGroup|.
1247
1299
1248
-
1. When setting the animation keyframes given |transform|, [=multiply=] |transform| by the inverse matrix of |groupContainerElement|'s [=old transform=].
1300
+
1. When setting the animation keyframes given |transform|, [=adjust nested view transition group transform|adjust=] |transform| given |groupContainerElement|.
1249
1301
1250
1302
Note: It is TBD how this is resolved when the old and new groups mismatch. See <a href="https://github.com/w3c/csswg-drafts/issues/10631">Issue 10631</a>.
1251
1303
</div>
@@ -1254,13 +1306,24 @@ When [[css-view-transitions-1#setup-transition-pseudo-elements-algorithm|setting
When [[css-view-transitions-1#style-transition-pseudo-elements-algorithm|updating the style of the transition pseudo-element]], perform the following steps before setting the [=captured element/group styles rule=], given a [=captured element=] |capturedElement|, given a |transform| and a {{ViewTransition}} |transition|:
1256
1308
1309
+
1. Let |childrenTransform| be |transform|.
1310
+
1257
1311
1. Set |capturedElement|'s [=transform from snapshot containing block=] to |transform|.
1258
1312
1259
1313
1. If |capturedElement|'s [=containing group name=] is not null, then:
1260
1314
1261
-
1. Let |groupContainerElement| be |transition|'s [=ViewTransition/named elements=][|capturedElement|'s [=containing group name=]].
1315
+
1. Let |groupContainerElement| be |transition|'s [=ViewTransition/named elements=][|capturedElement|'s [=containing group name=].
1316
+
1317
+
1. [=adjust nested view transition group transform|Adjust=] |transform| given |groupContainerElement|.
1318
+
1319
+
To <dfn>adjust nested view transition group transform</dfn> given a |transform| and a [=captured element=] |groupContainerElement|:
1320
+
1. Let |childrenTransform| be |groupContainerElement|'s [=transform from snapshot containing block=].
1321
+
1322
+
1. If |childrenTransform| is null, set it to |groupContainerElement|'s [=captured element/old transform=].
1323
+
1324
+
1. Translate |childrenTransform| by |groupContainerElement|'s [=captured element/old border width=]'s left and top components.
1262
1325
1263
-
1. [=Multiply=] |transform| by the inverse matrix of |groupContainerElement|'s [=transform from snapshot containing block=].
1326
+
1. Multiply |transform| by the inverse matrix of |childrenTransform|.
0 commit comments