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
extending the model in [[CSS-VIEW-TRANSITIONS-1]]:
125
125
126
-
* <a href="#cross-document-view-transitions">Cross-document view transitions</a>, including the ''@view-transition'' rule and the algorithms
126
+
* [[#cross-document-view-transitions|Cross-document view transitions]], including the ''@view-transition'' rule and the algorithms
127
127
that enable the cross-document view transition lifecycle.
128
-
* <a href="#selective-vt">Selective view transitions</a>, a way to match styles based on the existence of an [=active view transition=],
128
+
* [[#selective-vt|Selective view transitions]], a way to match styles based on the existence of an [=active view transition=],
129
129
and more specifically based on the active view transition being of a certain type.
130
-
* <a href="#shared-style-with-vt-classes">Sharing styles between view transition pseudo-elements</a>, a way to declare a style once,
131
-
and use it for multiple view transition pseudo-elements. This includes the 'view-transition-class' property, and <a href="#pseudo-element-class-additions">additions to named pseudo-elements</a>
130
+
* [[#shared-style-with-vt-classes|Sharing styles between view transition pseudo-elements]], a way to declare a style once,
131
+
and use it for multiple view transition pseudo-elements. This includes the 'view-transition-class' property, and [[#pseudo-element-class-additions|additions to named pseudo-elements]]
132
132
133
133
## Separating Visual Transitions from DOM Updates ## {#separating-transitions}
Each [=view transition name=] is a [=tree-scoped name=].
542
546
543
-
Note: Since currently only document-scoped view transitions are supported, only view transition names that are associated with the document are respected.
544
-
545
547
The values <css>none</css>, <css>auto</css>, and <css>match-element</css> are excluded from <<custom-ident>> here.
1. Otherwise, if |callbackOptions| is a {{StartViewTransitionOptions}}, then set |updateCallback| to |callbackOptions|'s {{StartViewTransitionOptions/update}}.
1618
+
In order to provide ergonomic behavior,
1619
+
the [=active view transition=] is exposed to script via a document property.
1558
1620
1559
-
1. If |this|'s [=active view transition=] is not null and its [=outbound post-capture steps=] is not null,
1560
-
then:
1621
+
<dl dfn-type=attribute dfn-for=Document>
1622
+
: <dfn>activeViewTransition</dfn>
1623
+
:: Returns the [=active view transition=] for the [=document=],
1624
+
or null if there is no active view transition.
1625
+
</dl>
1626
+
1627
+
Issue: Is this updated by a <code>rootEl.startViewTransition()</code> call, too?
1628
+
1629
+
## Additions to {{Element}} ## {#additions-to-element-api}
1630
+
1631
+
<xmp class=idl>
1632
+
partial interface Element {
1633
+
ViewTransition startViewTransition(
1634
+
optional (ViewTransitionUpdateCallback or StartViewTransitionOptions) callbackOptions = {}
(potentially canceling a conflicting [=view transition=]).
1644
+
1645
+
{{ViewTransitionUpdateCallback|updateCallback}}, if provided, is called asynchronously, once the current state of the element and its subtree is captured.
1646
+
Then, when the promise returned by {{ViewTransitionUpdateCallback|updateCallback}} fulfills,
1647
+
the new state of the element and its subtree is captured
1648
+
and the transition is initiated.
1649
+
1650
+
Note that {{ViewTransitionUpdateCallback|updateCallback}}, if provided, is *always* called,
1651
+
even if the transition cannot happen
1652
+
(e.g. due to duplicate `view-transition-name` values).
1653
+
The transition is an enhancement around the state change, so a failure to create a transition never prevents the state change.
1654
+
See [[#transitions-as-enhancements]] for more details on this principle.
1655
+
1656
+
If the promise returned by {{ViewTransitionUpdateCallback|updateCallback}} rejects, the transition is skipped.
1657
+
</dl>
1561
1658
1562
-
1. Let |preSkippedTransition| be a new {{ViewTransition}}in |this|'s [=relevant realm=] whose [=ViewTransition/update callback=] is |updateCallback|.
Note: The |preSkippedTransition|'s {{ViewTransition/types}} are ignored here because the transition is never activated.
1661
+
<div algorithm="start-el-vt-with-options">
1662
+
The [=method steps=] for <dfn method for=Element>startViewTransition(|callbackOptions|)</dfn> are as follows:
1565
1663
1566
-
1. [=Skip the view transition|Skip=] |preSkippedTransition| with an "{{InvalidStateError}}" {{DOMException}}.
1664
+
1. Let |document| be [=this's=][=relevant global object's=][=associated document=].
1665
+
1666
+
1. Let |viewTransition| be a new {{ViewTransition}} object in |document|'s [=relevant Realm=],
1667
+
with [=ViewTransition/root element=] set to [=this=].
1668
+
1669
+
1. If |callbackOptions| is a {{ViewTransitionUpdateCallback}},
1670
+
set |viewTransition|'s [=update callback=] to |callbackOptions|.
1671
+
1672
+
Otherwise, if |callbackOptions| is a {{StartViewTransitionOptions}}, then set |viewTransition|'s [=update callback=]
1673
+
to |callbackOptions|'s {{StartViewTransitionOptions/update}}.
1674
+
1675
+
1. If [=this=] doesn't have [=layout containment=],
1676
+
[=Skip the view transition|skip=] |viewTransition| with an "{{InvalidStateError}}" {{DOMException}}, and return |viewTransition|.
1567
1677
1568
-
1. Return |preSkippedTransition|.
1678
+
1. If |document|'s [=active view transition=] is not null and its [=outbound post-capture steps=] is not null,
1679
+
then:
1680
+
1681
+
1. [=Skip the view transition|Skip=] |viewTransition| with an "{{InvalidStateError}}" {{DOMException}}.
1682
+
1683
+
Note: The |viewTransition|'s {{ViewTransition/types}} are ignored here because the transition is never activated.
1684
+
1685
+
1. Return |viewTransition|.
1569
1686
1570
1687
Note: This ensures that a same-document transition that started after firing {{Window/pageswap}} is skipped.
1571
1688
1572
-
1. Let |viewTransition| be the result of running the [=method steps=] for {{Document/startViewTransition(updateCallback)}} given |updateCallback|.
1689
+
1. If [=this=]'s [=active view transition=] is not null,
1690
+
then [=skip the view transition|skip that view transition=]
1691
+
with an "{{AbortError}}" {{DOMException}} in [=this's=][=relevant Realm=].
1573
1692
1574
-
1. If |callbackOptions| is a {{StartViewTransitionOptions}}, set |viewTransition|'s [=ViewTransition/active types=] to a [=list/clone=] of {{StartViewTransitionOptions/types}} as a [=/set=].
1693
+
Note: This can result in two asynchronous [=ViewTransition/update callbacks=] running concurrently
1694
+
(and therefore possibly out of sequence):
1695
+
one for the [=this=]'s current [=active view transition=], and another for this |viewTransition|.
1696
+
As per the [design of this feature](#transitions-as-enhancements),
1697
+
it's assumed that the developer is using another feature or framework to correctly schedule these DOM changes.
1575
1698
1576
-
1. Return |viewTransition|.
1577
-
</div>
1699
+
1. Set [=this=]'s [=active view transition=] to |viewTransition|.
Note: The [=view transition=] process continues in [=setup view transition=],
1702
+
via [=perform pending transition operations=].
1580
1703
1581
-
In order to provide ergonomic behavior,
1582
-
the [=active view transition=] is exposed to script via a document property.
1704
+
1. If |callbackOptions| is a {{StartViewTransitionOptions}}, set |viewTransition|'s [=ViewTransition/active types=] to a [=list/clone=] of {{StartViewTransitionOptions/types}} as a [=/set=].
1583
1705
1584
-
<dl dfn-type=attribute dfn-for=Document>
1585
-
: <dfn>activeViewTransition</dfn>
1586
-
:: Returns the [=active view transition=] for the [=document=],
1587
-
or null if there is no active view transition.
1588
-
</dl>
1706
+
1. Return |viewTransition|.
1707
+
</div>
1589
1708
1590
1709
## The {{ViewTransition}} interface ## {#the-domtransition-interface}
1591
1710
@@ -1597,6 +1716,7 @@ the [=active view transition=] is exposed to script via a document property.
1597
1716
readonly attribute Promise<undefined> finished;
1598
1717
undefined skipTransition();
1599
1718
attribute ViewTransitionTypeSet types;
1719
+
readonly attribute Element transitionRoot;
1600
1720
};
1601
1721
</xmp>
1602
1722
@@ -1646,6 +1766,12 @@ the [=active view transition=] is exposed to script via a document property.
1646
1766
If this is called before {{ViewTransition/ready}} resolves, {{ViewTransition/ready}} will reject.
1647
1767
1648
1768
If {{ViewTransition/finished}} hasn't resolved, it will fulfill or reject along with {{ViewTransition/updateCallbackDone}}.
:: The {{ViewTransition}}'s [=ViewTransition/root element=].
1772
+
1773
+
For [=view transitions=] started on the {{Document}},
1774
+
this is the [=document element=].
1649
1775
</dl>
1650
1776
1651
1777
A {{ViewTransition}} has the following:
@@ -1708,6 +1834,10 @@ the [=active view transition=] is exposed to script via a document property.
1708
1834
1709
1835
: <dfn>outbound post-capture steps</dfn>
1710
1836
:: Null or a set of steps, initially null.
1837
+
1838
+
: <dfn>root element</dfn>
1839
+
:: An {{Element}},
1840
+
indicating which element is hosting the {{ViewTransition}}.
1711
1841
</dl>
1712
1842
1713
1843
The {{ViewTransition/finished}}[=getter steps=] are to return [=this's=][=ViewTransition/finished promise=].
@@ -1718,6 +1848,8 @@ the [=active view transition=] is exposed to script via a document property.
1718
1848
1719
1849
The {{ViewTransition/types}}[=getter steps=] are to return [=this=]'s [=ViewTransition/active types=].
1720
1850
1851
+
The {{ViewTransition/transitionRoot}}[=getter steps=] are to return [=this=]'s [=ViewTransition/root element=].
1852
+
1721
1853
### The {{ViewTransitionTypeSet}} Interface ### {#the-viewtransitiontypeset-interface}
1722
1854
1723
1855
<xmp class=idl>
@@ -2189,11 +2321,16 @@ It has the following [=struct/items=]:
2189
2321
and has a [=node document=] equal to |document|,
2190
2322
in [paint order](https://drafts.csswg.org/css2/#painting-order):
2191
2323
2192
-
<div class=note>We iterate in paint order to ensure that this order is cached in |namedElements|.
2193
-
This defines the DOM order for ::view-transition-group pseudo-elements, such that the element at the bottom of the paint stack generates the first pseudo child of ::view-transition.</div>
2324
+
Note: We iterate in paint order to ensure that this order is cached in |namedElements|.
2325
+
This defines the DOM order for ::view-transition-group pseudo-elements, such that the element at the bottom of the paint stack generates the first pseudo child of ::view-transition.
2194
2326
2195
2327
1. If any [=flat tree=] ancestor of this |element| [=skips its contents=], then [=continue=].
2196
2328
2329
+
1. If any [=flat tree=][=inclusive ancestor=] of this |element|,
2330
+
up to but not including |transition|'s [=ViewTransition/root element=],
2331
+
has ''contain: view-transition'',
2332
+
[=continue=].
2333
+
2197
2334
1. If |element| has more than one [=box fragment=], then [=continue=].
2198
2335
2199
2336
Note: We might want to enable transitions for fragmented elements in future versions.
@@ -2214,7 +2351,13 @@ It has the following [=struct/items=]:
2214
2351
2215
2352
1. Set |element|'s [=captured in a view transition=] to false.
2216
2353
2217
-
1. return failure.
2354
+
1. Return failure.
2355
+
2356
+
1. If <em>any other</em>[=active view transition=] contains |element|
2357
+
in its [=captured elements=],
2358
+
then for each such [=active view transition=],
2359
+
in [=tree order=] of their corresponding [=ViewTransition/root elements=],
2360
+
[=skip the view transition|skip=] that view transition with an "{{AbortError}}" {{DOMException}} in |document|’s [=relevant Realm=].
2218
2361
2219
2362
1. [=set/Append=] |transitionName| to |usedTransitionNames|.
0 commit comments