Skip to content

Commit 25c0f81

Browse files
noamrkhushalsagarvmpstr
authored
[css-view-transitions-2] Add transition types (#9385)
* Transition types Co-authored-by: Khushal Sagar <[email protected]> Co-authored-by: vmpstr <[email protected]>
1 parent 77e9601 commit 25c0f81

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

css-view-transitions-2/Overview.bs

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ spec:html
4141
text: run the animation frame callbacks; type: dfn;
4242
text: unload; type: dfn;
4343
text: update the rendering; type: dfn;
44+
spec:infra; type:dfn; text:list
4445
</pre>
4546

4647
<pre class=anchors>
@@ -205,7 +206,56 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface;
205206
```
206207
</div>
207208

209+
# Pseudo-classes # {#pseudo-classes}
208210

211+
## Active View Transition Pseudo-class '':active-view-transition()''' ## {#the-active-view-transition-pseudo}
212+
213+
The <dfn id='active-view-transition-pseudo'>:active-view-transition(<<vt-type-selector>>)</dfn> pseudo-class applies to the root element of the document, if it has a matching [=active view transition=].
214+
It has the following syntax definition:
215+
216+
<pre class=prod>
217+
:active-view-transition(<<vt-type-selector>>)
218+
<dfn>&lt;vt-type-selector></dfn> = '*' | <<custom-ident>>#
219+
</pre>
220+
221+
An ''::active-view-transition()'' pseudo-class matches the [=document element=] when it has an non-null [=active view transition=] |viewTransition|, for which any of the following are true:
222+
223+
* The <<vt-type-selector>> is ''*''
224+
* |viewTransition|'s [=ViewTransition/active types=] [=list/contains=] at least one of the <<custom-ident>> values of the <<vt-type-selector>>.
225+
226+
<div class=example>
227+
For example, the developer might start a transition in the following manner:
228+
```js
229+
document.startViewTransition({update: updateTheDOMSomehow, types: ["slide-in", "reverse"]});
230+
```
231+
232+
This will activate any of the following '::active-view-transition()'' selectors:
233+
```css
234+
:root:active-view-transition(slide-in) {}
235+
:root:active-view-transition(reverse) {}
236+
:root:active-view-transition(slide-in, reverse) {}
237+
:root:active-view-transition(slide-in, something-else) {}
238+
:root:active-view-transition(*) {}
239+
```
240+
241+
While starting a transition without selecting transition types, would only activate '::active-view-transition()'' with ''*'':
242+
243+
```js
244+
document.startViewTransition(updateTheDOMSomehow);
245+
// or
246+
document.startViewTransition({update: updateTheDOMSomehow});
247+
```
248+
249+
```css
250+
/* This would be active */
251+
:root { }
252+
:root:active-view-transition(*) {}
253+
254+
/* This would not be active */
255+
:root:active-view-transition(slide-in) {}
256+
:root:active-view-transition(any-type-at-all-except-star) {}
257+
```
258+
</div>
209259

210260
# CSS rules # {#css-rules}
211261

@@ -264,6 +314,34 @@ Note: this event is fired when [=reveal document|revealing a document=].
264314
The <dfn attribute for=PageRevealEvent>viewTransition</dfn> [=getter steps=] are to return the
265315
[=inbound cross-document view-transition=] for [=this's=] [=relevant global object's=] [=associated document=].
266316

317+
## Additions to {{Document}} ## {#additions-to-document-api}
318+
319+
<xmp class=idl>
320+
dictionary StartViewTransitionOptions {
321+
UpdateCallback? update = null;
322+
sequence<DOMString>? types = null;
323+
};
324+
325+
partial interface Document {
326+
327+
ViewTransition startViewTransition((UpdateCallback or StartViewTransitionOptions?) callbackOptionsOrNull);
328+
};
329+
</xmp>
330+
331+
### {{Document/startViewTransition(options)}} Method Steps ### {#ViewTransition-start-with-options}
332+
333+
<div algorithm="start-vt-with-options">
334+
The [=method steps=] for <dfn method for=Document>startViewTransition(|callbackOptionsOrNull|)</dfn> are as follows:
335+
336+
1. If |callbackOptionsOrNull| is an {{UpdateCallback}} or null, then run the [=method steps=] for {{Document/startViewTransition(updateCallback)}} given |callbackOptionsOrNull| and return the result.
337+
338+
1. Let |viewTransition| be the result of running [=method steps=] for {{Document/startViewTransition(updateCallback)}} given |callbackOptionsOrNull|'s {{StartViewTransitionOptions/update}}.
339+
340+
1. Set |transition|'s [=ViewTransition/active types=] to |callbackOptionsOrNull|'s {{StartViewTransitionOptions/types}}.
341+
342+
1. Return |viewTransition|.
343+
</div>
344+
267345

268346

269347
# Algorithms # {#algorithms}
@@ -283,6 +361,9 @@ The <dfn attribute for=PageRevealEvent>viewTransition</dfn> [=getter steps=] are
283361
<dl dfn-for=ViewTransition>
284362
: <dfn>is inbound cross-document transition</dfn>
285363
:: a boolean, initially false.
364+
365+
: <dfn>active types</dfn>
366+
:: Null or a [=list=] of strings, initially null.
286367
</dl>
287368

288369
## Monkey patches to HTML ## {#monkey-patch-to-html}

0 commit comments

Comments
 (0)