Skip to content

Commit 5719f78

Browse files
authored
[css-view-transitions-2] Spec view-transition-scope (#13390)
* Spec view-transition-scope
1 parent 7e27ad7 commit 5719f78

File tree

1 file changed

+86
-19
lines changed

1 file changed

+86
-19
lines changed

css-view-transitions-2/Overview.bs

Lines changed: 86 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ Note: An <code>element.startViewTransition()</code> call does not update
639639
[=Skip the view transition|skip=] |viewTransition| with an "{{InvalidStateError}}" {{DOMException}}.
640640

641641
1. If [=this=] is not the [=/root element|document root element=],
642-
force [=this=] to have [=layout containment=] for the duration of the transition.
642+
force [=this=] to have both [=layout containment=] and [=view transition scoping=] for the duration of the transition.
643643

644644
1. If |document|'s [=active view transition=] is not null and its [=outbound post-capture steps=] is not null,
645645
then:
@@ -935,29 +935,94 @@ the active view transition of an element is exposed to script via a property on
935935
- Are [[css-transforms-2#grouping-property-values|flattened in 3D transforms]].
936936
- Form a [=backdrop root=].
937937

938-
## Isolating Scoped View Transition Names: the ''contain/view-transition'' containment value ## {#contain-view-transition}
938+
## Isolating Scoped View Transition Names: the 'view-transition-scope' property ## {#view-transition-scope-prop}
939939

940-
ISSUE: This property is subject to change, see https://github.com/w3c/csswg-drafts/issues/13123.
941-
The behavior described here is likely to remain, but the property is likely to change.
942-
943-
<pre class="propdef partial">
944-
Name: contain
945-
New Values: view-transition
940+
<pre class="propdef">
941+
Name: view-transition-scope
942+
Value: none | auto
943+
Initial: none
944+
Inherited: no
945+
Percentages: n/a
946+
Computed Value: as specified
947+
Animation type: discrete
946948
</pre>
947949

948-
The ''contain: view-transition'' value establishes <dfn export>view transition name containment</dfn> on an element.
949-
This causes any [=document-scoped view transition names=] to only be visible
950-
for [=view transitions=] scoped to this element or its descendants.
950+
Note: Although 'view-transition-scope' is [=discrete|discretely animatable=],
951+
it only has an effect during 'view-transition-name' discovery
951952

952-
Note: Most elements running a [=scoped view transition=]
953-
should use [=view transition name containment=],
954-
to ensure that their [=document-scoped view transition names=]
955-
don't accidentally interfere with other [=scoped view transitions=].
956-
Otherwise, two similar elements running the same [=scoped view transition=],
957-
expecting the same-named descendants,
958-
will see each other's names and abort
959-
(since [=view transitions=] don't allow multiple elements to have the same 'view-transition-name').
953+
<dl dfn=type=value dfn-for=view-transition-scope>
954+
: <dfn>none</dfn>
955+
:: This property has no effect on 'view-transition-name' discoverability.
960956

957+
: <dfn>auto</dfn>
958+
:: Discoverability of 'view-transition-name' is limited to the subtree of this element.
959+
This is done by applying <dfn>view transition scoping</dfn>.
960+
Such scoping means that any transitions that originate outside of the element
961+
will not discover a non-none 'view-transition-name' either on this element
962+
or in its flat-tree descedants.
963+
964+
<div class=example>
965+
```html
966+
<style>
967+
.scope { view-transition-scope: auto; }
968+
#a { view-transition-name: a; }
969+
#b { view-transition-name: b; }
970+
#c { view-transition-name: c; }
971+
#d { view-transition-name: d; }
972+
</style>
973+
974+
<div id=a>
975+
<div id=b class=scope>
976+
<div id=c></div>
977+
</div>
978+
<div id=d></div>
979+
</div>
980+
981+
<script>
982+
...
983+
a.startViewTransition(); // Will discover "a" and "d" view-transition-names
984+
b.startViewTransition(); // Will discover "b" and "c" view-transition-names
985+
...
986+
</script>
987+
```
988+
</div>
989+
990+
Note: Starting a transition implies that [=this=] element has ''view-transition-scope: auto''
991+
for the duration of the transition.
992+
993+
<div class=example>
994+
```html
995+
<style>
996+
#a { view-transition-name: a; }
997+
#b { view-transition-name: b; }
998+
#c { view-transition-name: c; }
999+
#d { view-transition-name: d; }
1000+
</style>
1001+
1002+
<div id=a>
1003+
<div id=b>
1004+
<div id=c></div>
1005+
</div>
1006+
<div id=d></div>
1007+
</div>
1008+
1009+
<script>
1010+
...
1011+
b.startViewTransition(); // Will discover "b" and "d" view-transition-names
1012+
1013+
// While b's transition is active and running, the following will only discover
1014+
// "a" and "d" view transition names, since b has a forced view-transition-scope: auto.
1015+
b.startViewTransition()
1016+
...
1017+
</script>
1018+
```
1019+
</div>
1020+
</dl>
1021+
1022+
Note: Most elements running or planning to run a [=scoped view transition=]
1023+
should use ''view-transition-scope: auto'', to ensure that their
1024+
[=document-scoped view transition names=] don't accidentally interfere with
1025+
other [=scoped view transitions=] in the ancestor chain.
9611026

9621027
# Nested View Transition Groups # {#nested-vt}
9631028

@@ -3184,6 +3249,7 @@ To <dfn>adjust nested view transition group transform</dfn> given a |transform|
31843249
1. Decrement [=this=]'s [=wait until promise count=].
31853250

31863251
Note: If [=this=]'s [=wait until promise count=] is 0, the transition will finish at the next [=rendering opportunity=].
3252+
</div>
31873253

31883254
## [=Handle transition frame=] ## {#handle-transition-frame-algorithm}
31893255

@@ -3397,6 +3463,7 @@ This appendix is <em>informative</em>.
33973463
Changes from <a href="https://www.w3.org/TR/2024/WD-css-view-transitions-2-20240516/">2024-05-16 Working Draft</a>
33983464
</h3>
33993465

3466+
* Replace `contain: view-transition` with `view-transition-scope` property (<a href="https://github.com/w3c/csswg-drafts/issues/13123">pending #13123</a>)
34003467
* Reorder sections, editorial changes, added several issues, updated scoped view transition wording.
34013468
* Add waitUntil() (<a href="https://github.com/w3c/csswg-drafts/issues/9901">#9901</a>)
34023469
* First pass at layered capture (<a href="https://github.com/w3c/csswg-drafts/issues/10585">#10585</a>)

0 commit comments

Comments
 (0)