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] Allow auto as a keyword (#10922)
* [css-view-transitions-2] Allow `auto` as a keyword
`auto` resolves to either the element's ID, or to a unique identifier
that is stable for the duration of the transition and is not web-observable.
Resolution: #8320 (comment)Closes#8320
* Fix refs
* Tighten definition of unique string
* Update css-view-transitions-2/Overview.bs
Co-authored-by: Khushal Sagar <63884798+khushalsagar@users.noreply.github.com>
* Handle scoping
* Change scoping text
* Change scoping text
* Update Overview.bs
Co-authored-by: Khushal Sagar <63884798+khushalsagar@users.noreply.github.com>
---------
Co-authored-by: Khushal Sagar <63884798+khushalsagar@users.noreply.github.com>
For an element to participate in a view transition, it needs to receive a unique 'view-transition-name'.
763
+
This can be tedious and verbose when multiple elements are involved in the same view transition, especially in cases where many of those are same-element transitions,
764
+
as in, the element has the same 'view-transition-name' in the old and new state.
765
+
766
+
To make this easier, setting the 'view-transition-name' to ''view-transition-name/auto'' would generate a 'view-transition-name' for the element, or take it from the element's [=Element/id=] if present.
767
+
768
+
## Examples ## {#auto-vt-name-example}
769
+
770
+
<div class="example">
771
+
In this example, view transition is used to sort a list in an animated way:
772
+
773
+
```html
774
+
<ul>
775
+
<li>Item 1</li>
776
+
<li>Item 2</li>
777
+
<li>Item 3</li>
778
+
<li>Item 4</li>
779
+
...
780
+
</ul>
781
+
```
782
+
783
+
Ordinarily, each of these items would have to receive a unique 'view-transition-name':
784
+
785
+
```css
786
+
li:nth-child(1) { view-transition-name: item1; }
787
+
li:nth-child(2) { view-transition-name: item1; }
788
+
li:nth-child(3) { view-transition-name: item1; }
789
+
li:nth-child(4) { view-transition-name: item1; }
790
+
...
791
+
```
792
+
793
+
With ''view-transition-name/auto'', this CSS would work:
794
+
795
+
```css
796
+
li {
797
+
view-transition-name: auto;
798
+
}
799
+
```
800
+
</div>
801
+
802
+
## Additions to 'view-transition-name' ## {#additions-to-vt-name}
803
+
804
+
In addition to the existing values, the 'view-transition-name' also accepts an <dfn for=view-transition-name type=value export>auto</dfn> keyword.
805
+
To resolve the [=used value=] of 'view-transition-name' for |element|:
806
+
1. Let |computed| be the [=computed value=] of 'view-transition-name'.
807
+
1. If |computed| is <css>none</css>, return null.
808
+
1. If |computed| is a <<custom-ident>>, return |computed|.
809
+
1. Assert: |computed| is <css>auto</css>.
810
+
1. If |element| has an associated [=Element/id=], and |computed| is associated with the same [=tree/root=] as |element|'s [=tree/root=], then return the value of |element|'s [=Element/id=].
811
+
812
+
Note: this means that a ''::part()'' pseudo-element wouldn't resolve to its matching element's [=Element/id=].
813
+
814
+
1. Return a unique string. The string should remain consistent and unique for this element and {{Document}}, at least for the lifetime of |element|'s [=node document=]'s [=active view transition=].
815
+
816
+
Note: this string is not web-observable, and is used for addressing the element in internal algorithms.
817
+
818
+
Note: When used in a cross-document view transition, generated <css>auto</css> values never match, resulting in separate ''::view-transition-group()'' pseudo-elements, one exiting and one entering.
819
+
820
+
A 'view-transition-name' generated by <css>auto</css> is a [=tree-scoped name=].
0 commit comments