[css-view-transitions-1] CSS selector syntax for generated elements and API names · Issue #7788 · w3c/csswg-drafts (original) (raw)

Folks at TPAC asked for the pseudo-element names to be reduced so we had a bikeshedding session, and here's what we came up with.

@fantasai @mirisuzanne I'm interested to hear your thoughts on this. We've tried to go for brevity rather than full namespacing.

"Shared element transition" becomes "View transition"

Rationale:

page-transition-tag becomes

view-name

.header { /* old / page-transition-tag: header; / new */ view-name: header; }

This causes pseudos to be created so the header can be animated independently during the transition.

Rationale:

html::page-transition becomes

html::view-root

This is the root of the pseudo-element tree that contains all the transition parts.

Rationale:

html::page-transition-container(header) becomes

html::view(header)

This is the pseudo-element that represents a view of an element during the transition. In this case it's the view of the 'header'. Developers target this to customize the animation. It's a child of html::view-root.

Rationale:

html::page-transition-image-wrapper(header) becomes

html::view-image-group(header)

This wraps the view's images, providing isolation for their blending (to allow a true cross-fade). In this case it's the image-group for the 'header'. It's a child of html::view.

Rationale:

html::page-transition-outgoing-image(header) and

html::page-transition-incoming-image(header) become
html::view-before(header) and
html::view-after(header) respectively

These are the replaced elements that represent the before and after view. In their default animation, they cross-fade.

Rationale:

document.createTransition() becomes

document.createViewTransition()

This is the API developers use to create a transition between states in an SPA.

Rationale:

Example

Taking the slide-from-the-side example from the breakout at TPAC:

Old:

::page-transition-outgoing-image(root) { animation: 500ms ease-out both slide-to-left; }

::page-transition-incoming-image(root) { animation: 500ms ease-out both slide-from-right; }

New:

::view-before(root) { animation: 500ms ease-out both slide-to-left; }

::view-after(root) { animation: 500ms ease-out both slide-from-right; }

(I've omitted the keyframes since they're the same in both)

Resulting pseudo-tree

::view-root
├ ::view(custom-ident)
|  └─ ::view-image-group(custom-ident)
|     ├─ ::view-before(custom-ident)
|     └─ ::view-after(custom-ident)
└ ::view(different-ident)
   └─ ::view-image-group(different-ident)
      ├─ ::view-before(different-ident)
      └─ ::view-after(different-ident)

(thanks @mirisuzanne!)