-
Notifications
You must be signed in to change notification settings - Fork 756
[css-view-transitions-2] Specify 'view-transition-class' and corresponding algorithms #9773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
d49b54a
34232c3
55f5e03
3472269
d918977
8889771
173a37a
617f5e7
debe3f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
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
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -34,6 +34,9 @@ spec:css-view-transitions-1; | |||||
| text: setup view transition; type: dfn; | ||||||
| spec:dom; type:dfn; text:document | ||||||
| spec:css22; type:dfn; text:element | ||||||
| spec:selectors-4; type:dfn; | ||||||
| text:selector | ||||||
| text:type selector | ||||||
| spec:html | ||||||
| text: latest entry; type: dfn; | ||||||
| text: was created via cross-origin redirects; type: dfn; | ||||||
|
|
@@ -199,6 +202,83 @@ spec:infra; type:dfn; text:list | |||||
| ``` | ||||||
| </div> | ||||||
|
|
||||||
| ### Example of using 'view-transition-class' ### {#vt-class-example} | ||||||
noamr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| In addition to cross-document view-transitions, this document specifies a way to use the same view-transition style | ||||||
noamr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| for multiple elements without having to replicate the corresponding pseudo-elements. | ||||||
noamr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| <div class="example"> | ||||||
| This example creates a transition with each box participating under its own name, while applying | ||||||
| a 1-second duration to the animation of all the boxes: | ||||||
|
|
||||||
| ```html | ||||||
| <div class="box" id="red-box"></div> | ||||||
| <div class="box" id="green-box"></div> | ||||||
| <div class="box" id="yellow-box"></div> | ||||||
| ``` | ||||||
|
|
||||||
| ```css | ||||||
| div.box { | ||||||
| view-transition-class: any-box; | ||||||
| width: 100px; | ||||||
| height: 100px; | ||||||
| } | ||||||
| #red-box { | ||||||
| view-transition-name: red-box; | ||||||
| background: red; | ||||||
| } | ||||||
| #green-box { | ||||||
| view-transition-name: green-box; | ||||||
| background: green; | ||||||
| } | ||||||
| #yellow-box { | ||||||
| view-transition-name: yellow-box; | ||||||
| background: yellow; | ||||||
| } | ||||||
|
|
||||||
| /* The following style would apply to all the boxes, thanks to 'view-transition-class' */ | ||||||
| ::view-transition-group(*.any-box) { | ||||||
| animation-duration: 1s; | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| </div> | ||||||
|
|
||||||
|
|
||||||
| # CSS Properties # {#css-properties} | ||||||
|
|
||||||
| ## Applying the same style to multiple participating elements: the 'view-transition-class' property ## {#view-transition-class-prop} | ||||||
|
|
||||||
| <pre class=propdef> | ||||||
| Name: view-transition-class | ||||||
| Value: none | <<custom-ident>>* | ||||||
| Initial: none | ||||||
| Inherited: no | ||||||
| Percentages: n/a | ||||||
| Computed Value: as specified | ||||||
| Animation type: discrete | ||||||
| </pre> | ||||||
|
|
||||||
| The 'view-transition-class' works alongside 'view-transition-name', and is read at the same time | ||||||
|
||||||
| 'view-transition-name' is read. But unlike 'view-transition-name', 'view-transition-class' doesn't | ||||||
| have to be unique - an element can have several view-transition classes, and the same 'view-transition-class' | ||||||
| can apply to multiple elements. 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 | ||||||
|
||||||
| only to apply styles using the view-transition pseudo-elements | ||||||
| (''::view-transition-group()'', ''::view-transition-image-pair()'', ''::view-transition-old()'', ''::view-transition-new()''). | ||||||
|
|
||||||
| <dl dfn-type=value dfn-for=view-transition-class> | ||||||
| : <dfn>none</dfn> | ||||||
| :: No class would apply to the [=/element=], and pseudo-elements would have to match its 'view-transition-name'. | ||||||
noamr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| : <dfn><<custom-ident>>*</dfn> | ||||||
| :: All of the specified <<custom-ident>> values (apart from <css>none</css>) apply as classes for the [=/element=]. | ||||||
|
||||||
| :: All of the specified <<custom-ident>> values (apart from <css>none</css>) apply as classes for the [=/element=]. | |
| :: All of the specified <<custom-ident>> values (apart from <css>none</css>) are applied to the [=named view-transition pseudo-elements=] generated for this element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be defined a bit better I think, using [=captured element/class list=] perhaps, or reference the algorithm below.
vmpstr marked this conversation as resolved.
Show resolved
Hide resolved
noamr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"would only match an element" is confusing. Can we phrase this as, if the [=captured element/class list=] value in https://www.w3.org/TR/css-view-transitions-1/#viewtransition-named-elements for the pseudo-element's view-transition-name contains all of those values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
noamr marked this conversation as resolved.
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "view transition class algorithms"? Since this section is the set of algorithm changes required for the view-transition-class property.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wdyt about pulling steps 2-10 of this loop into a separate algorithm : https://www.w3.org/TR/css-view-transitions-1/#capture-old-state-algorithm:~:text=in%20the%20algorithm.-,For%20each%20element%20in%20captureElements,-%3A. That's where we're setting everything on the "capture" struct given an "element".
Then this spec, "add the following steps to this algorithm".
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose the same thing here for this loop: https://www.w3.org/TR/css-view-transitions-1/#capture-new-state-algorithm:~:text=set%20of%20strings.-,For%20each%20element%20of%20every%20element%20that%20is%20connected%2C%20and%20has%20a%20node%20document%20equal%20to%20to%20document%2C%20in%20paint%20order%3A,-If%20any%20flat.
But I also don't want to explode the number of sub-algorithms in the L1 spec. So if you have any other idea to better link to the exact spot that's good to. Another suggestion is, "Do this after step 4.7 of https://www.w3.org/TR/css-view-transitions-1/#capture-the-new-state". If you like that, I'm happy with the same for above as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's monkey-patchy, I don't like that... let's see what Tab has to say.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind adding a similar sub-heading above for "cross-document view transitions".