Skip to content

Commit bcf2ddd

Browse files
authored
Update explainer by removing captureAndHold (WICG#142)
1 parent 047b796 commit bcf2ddd

1 file changed

Lines changed: 36 additions & 27 deletions

File tree

‎explainer.md‎

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,9 @@ configured by UA and/or developer stylesheets using z-index.
349349

350350
- [Open question](https://github.com/WICG/shared-element-transitions/issues/23):
351351
How should the default UA animation order these elements? And also handle a
352-
change in associated elements between the 2 pages.
352+
change in associated elements between the 2 pages. Currently they are ordered
353+
by paint order. For instance, parents are ordered before children, and
354+
negative z-index elements are ordered before positive z-index elements.
353355

354356
### How are transition elements painted?
355357

@@ -402,28 +404,28 @@ happen.
402404
### Via CSS
403405

404406
Page-A can offer an element to be used in a transition via CSS, using the
405-
`page-transition-tag` property:
407+
`page-transition-tag` property, with a default value of `none`:
406408

407409
```css
408-
:root {
409-
page-transition-tag: root;
410-
}
411410
.header {
412411
page-transition-tag: header;
413412
}
413+
.content {
414+
page-transition-tag: content;
415+
}
414416
```
415417

416418
The tag is a
417-
[`<custom-ident>`](https://www.w3.org/TR/css-values/#identifier-value). It's
418-
recommended to use 'root' to refer to the bottommost element that covers the
419-
viewport, which is usually `:root`, but this isn't enforced.
419+
[`<custom-ident>`](https://www.w3.org/TR/css-values/#identifier-value).
420420

421-
Page-A must offer elements to use for a transition, otherwise no transition will
422-
happen.
421+
Note that `root` is a reserved tag, which is automatically applied to the
422+
`:root` element, which is always captured during the transition.
423+
424+
Also note that since `none` is the default value for this property, it is
425+
reserved and is unavailable for use during the transition.
423426

424427
A tag must be unique for a document. If multiple elements share a tag, the
425-
transition will be abandoned. In future, multiple elements may be able to share
426-
a tag, but it isn't yet clear how that would work.
428+
transition will be abandoned.
427429

428430
The other modes mentioned in this document, such as "computed style + content
429431
image", and "retaining hierarchy" will be exposed via other CSS properties, and
@@ -469,7 +471,9 @@ This proposal will change that to `PageHideTransitionEvent`, which extends
469471
used in the transition.
470472
- `element` - the element.
471473
- `tag` - the tag name. Can be `null` to un-set this element. This is
472-
equivalent to `page-transition-tag`.
474+
similar to `page-transition-tag`. One difference is that the script API
475+
allows an element to have multiple tags set on it. This is supported for an
476+
effect where a single element transitions to two distinct elements.
473477
- `options` - reserved for future use. This is where "computed style + content
474478
image" and "retaining hierarchy" modes will be exposed.
475479
- `event.transition.setData(data)` - An object that is structured-cloned and
@@ -486,11 +490,10 @@ Once `pagehide` has dispatched:
486490
`page-transition-tag`.
487491
1. Add/remove offered elements according to `setElement` calls.
488492
1. If multiple elements share the same tag, abandon the transition.
489-
1. If at least one element remains offered, a transition can go ahead.
493+
1. A transition happens.
490494

491-
As a result of the above, if an element is offered via CSS and `setElement`,
492-
then `setElement` wins. If there are multiple calls to `setElement` for the same
493-
element, the last wins.
495+
Note that this can result in a single element being assigned multiple tags. This
496+
will result in multiple transitions originating from the same element.
494497

495498
Gathering offered elements _after_ the dispatch of `pagehide` means the
496499
developer can use a mix of the CSS and JS methods. For instance, the developer
@@ -530,6 +533,10 @@ These pseudo-element selectors provide access to these pseudo-elements via
530533

531534
Using '\*' instead of a tag selects the equivalent element for every tag.
532535

536+
Issue: It would be nice to be consistent with the '\*' CSS selector in that we
537+
would like `::page-transition(*)` to have a lower specificity than
538+
`::page-transition(tag)`.
539+
533540
#### Default styles
534541

535542
These styles will be in the UA stylesheet:
@@ -677,10 +684,10 @@ async function doTransition() {
677684

678685
- `transition.setElement(element, tag, options)` - Same arguments as the MPA
679686
API.
680-
- `transition.captureAndHold()` - Capture any currently offered element as
681-
"outgoing", and hold the current rendered view. Resolves when ready.
682-
- `transition.start()` - Capture any offered element as "incoming", and match
683-
them to outgoing elements as in the MPA model.
687+
- `transition.start(callback)` - Asynchornously capture any offered element as
688+
"outgoing". When finished, invoke the callback. When the callback finishes
689+
running, capture any new elements as "incoming". Match outgoing and incoming
690+
elements and begin transition.
684691
- `transition.ignoreCSSTaggedElements()` - Same as MPA API.
685692
- `transition.abandon()` - Same as MPA API.
686693

@@ -689,15 +696,12 @@ for `createDocumentTransition` to be small and have CSS handle the rest:
689696

690697
```js
691698
document.createDocumentTransition(async (transition) => {
692-
await transition.captureAndHold();
693-
await coolFramework.changeTheDOMToPageB();
694-
transition.start();
699+
transition.start(async () => { await coolFramework.changeTheDOMToPageB() });
695700
});
696701
```
697702

698-
Calling `setElement` before `captureAndHold` means that element will be captured
699-
as both "outgoing" and "incoming", unless the element is removed before
700-
`start()`, or is assigned a different tag via `setElement`.
703+
Calling `setElement` before `start` means that element will be captured as both
704+
"outgoing". Calling it within the `start` callback will mark them as "incoming".
701705

702706
# Relation to `element()`
703707

@@ -722,6 +726,11 @@ similarly named functions (e.g. `element-children()`).
722726
single image mode transition built using the existing element() support in
723727
Firefox.
724728

729+
Note that we are not currently planning on exposing the stand-alone method of
730+
capturing the elements, as would be possible with an `element()` function.
731+
Instead, the capturing and displaying the contents via the pseudo elements is an
732+
internal detail.
733+
725734
# Security/Privacy Considerations
726735

727736
The security considerations below cover same-origin transitions.

0 commit comments

Comments
 (0)