Re: [csswg-drafts] [css-view-transitions-1] Handling cases where transition constraints are broken mid transition (#7882)

In a transition group that has a 'new' component (as in, the end state of the transition is linked to a renderable element in the document), that element controls the final width/height/position of the `::view-transition-group` and the natural size and image of the `::view-transition-new`.

If that element changes layout or appearance, the `::view-transition-group` and `::view-transition-new` is updated.

But, what should happen if, mid-transition:

- That element is no longer renderable (eg `display: none` or removed from the document)
- That element becomes renderable again

And does the behaviour change depending on if the `::view-transition-group` has a `::view-transition-old` (as in, it's transitioning 'from' a captured element)?

The following options assume that the linking of source elements to `::view-transition-new` via their `view-transition-name` is performed once. As in, changes to elements' `view-transition-name` do not impact the current transition.

It also assumes that "the element is no longer renderable" check is performed in the render steps, when the view transition currently updates its state per frame.

---

## Option 1: Skip the transition

If the transition starts with a `::view-transition-new`, then it's required that the source element is capturable until the end of the transition. Otherwise, the remainder of the transition is skipped.

## Option 2: Adapt the transition, no backsies

If the element is no longer renderable:

If the group has a `::view-transition-old`, then the group's associated `::view-transition-new` is removed from the group. The size & transform of the `::view-transition-group` becomes the same as its 'from' keyframe (meaning it stays in the same size and position as the old element).

This puts the `::view-transition-group` into a state as if the `::view-transition-new` wasn't there in the first place.

However, this would cause `::view-transition-old:only-child` to match, and which could cause new animations to start mid-way through the transition.

If the group does not have a `::view-transition-old`, then the `::view-transition-group` is removed.

If the element becomes renderable again, no action is taken.

## Option 2: Adapt the transition, with backsies

If the element is no longer renderable, the group's associated `::view-transition-new` becomes 0x0, transparent.

If the group has a `::view-transition-old`, the size & transform of the `::view-transition-group` becomes the same as its 'from' keyframe (meaning it stays in the same size and position as the old element).

This is mostly as if `::view-transition-new` wasn't there in the first place, but not quite.

If the group does not have a `::view-transition-old`, the size & transform of the `::view-transition-group` becomes 0x0, with no transform (placing the group in the top-left of the snapshot viewport).

If the element becomes renderable again, the state is updated again, allowing the element to reappear.

---

The two "adapt the transition" seem to have weird trade-offs, so I think I'm happiest with option 1.

-- 
GitHub Notification of comment by jakearchibald
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7882#issuecomment-1339334717 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 6 December 2022 13:10:18 UTC