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] Specify 'view-transition-class' and corresponding algorithms (#9773)
* [css-view-transitions-2] Add 'view-transition-class'
A `view-transition-class` property allows specifying view-transition pseudo-elements
that apply to multiple participating elements without having to replicate them.
In this PR:
- Specifying `view-transition-class`
- Extending the pseudo-element syntax to support `::view-transition-foo(name.class)`
- Extending the capture algorithms and data structure to capture the classes
- Added a simple example for using classes
Based on [this resolution](#8319 (comment)).
Closes#8319
---------
Co-authored-by: Khushal Sagar <63884798+khushalsagar@users.noreply.github.com>
Co-authored-by: vmpstr <vmpstr@chromium.org>
view-transition-class provides a way to use the same style
211
+
for multiple view transition pseudo elements without having to replicate the corresponding pseudo-elements.
212
+
213
+
<div class="example">
214
+
This example creates a transition with each box participating under its own name, while applying
215
+
a 1-second duration to the animation of all the boxes:
216
+
217
+
```html
218
+
<div class="box" id="red-box"></div>
219
+
<div class="box" id="green-box"></div>
220
+
<div class="box" id="yellow-box"></div>
221
+
```
222
+
223
+
```css
224
+
div.box {
225
+
view-transition-class: any-box;
226
+
width: 100px;
227
+
height: 100px;
228
+
}
229
+
#red-box {
230
+
view-transition-name: red-box;
231
+
background: red;
232
+
}
233
+
#green-box {
234
+
view-transition-name: green-box;
235
+
background: green;
236
+
}
237
+
#yellow-box {
238
+
view-transition-name: yellow-box;
239
+
background: yellow;
240
+
}
241
+
242
+
/* The following style would apply to all the boxes, thanks to 'view-transition-class' */
243
+
::view-transition-group(*.any-box) {
244
+
animation-duration: 1s;
245
+
}
246
+
```
247
+
248
+
</div>
249
+
250
+
251
+
# CSS Properties # {#css-properties}
252
+
253
+
## Applying the same style to multiple participating elements: the 'view-transition-class' property ## {#view-transition-class-prop}
254
+
255
+
<pre class=propdef>
256
+
Name: view-transition-class
257
+
Value: none | <<custom-ident>>*
258
+
Initial: none
259
+
Inherited: no
260
+
Percentages: n/a
261
+
Computed Value: as specified
262
+
Animation type: discrete
263
+
</pre>
264
+
265
+
The 'view-transition-class' can be used to apply the same style rule to multiple [=named view transition pseudo-elements=] which may have a different 'view-transition-name'.
266
+
While 'view-transition-name' is used to match between the element in the old state with its corresponding element in the new state, 'view-transition-class' is used
267
+
only to apply styles using the view-transition pseudo-elements
Note that 'view-transition-class' by itself doesn't mark an element for capturing, it is only used as an additional
271
+
way to style an element that already has a 'view-transition-name'.
272
+
273
+
<dl dfn-type=value dfn-for=view-transition-class>
274
+
: <dfn>none</dfn>
275
+
:: No class would apply to the [=named view transition pseudo-elements=] generated for this element.
276
+
277
+
: <dfn><<custom-ident>>*</dfn>
278
+
:: All of the specified <<custom-ident>> values (apart from <css>none</css>) are applied when used in [=named view transition pseudo-element=] selectors.
279
+
<css>none</css> is an invalid <<custom-ident>> for 'view-transition-class', even when combined with other <<custom-ident>>s.
280
+
281
+
Note: If the same 'view-transition-name' is specified for an element both in the old and new states of the transition,
282
+
only the 'view-transition-class' values from the new state apply. This also applies for cross-document view-transitions:
283
+
classes from the old document would only apply if their corresponding 'view-transition-name' was not specified in the new document.
284
+
</dl>
285
+
202
286
# Pseudo-classes # {#pseudo-classes}
203
287
204
288
## Active View Transition Pseudo-class '':active-view-transition()''' ## {#the-active-view-transition-pseudo}
0 commit comments