-
Notifications
You must be signed in to change notification settings - Fork 637
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
[css-view-transitions-2] Allow to control whether make a particular group when the named element was there only in one side #8528
Comments
This isn't currently possible, because the old view is captured before the new view is available. As a developer, you could create the new view, but detached from the document, then crawl the DOM to see if the new view has an equivalent In future, we want to work on 'nested transitions', which allows you to specify that one |
My thoughts exactly, nested transitions groups should help. But this brings up a good point, would authors need this nesting to be conditional based on whether a view-transition-name has both old/new images or only one of them. |
That would be the only way to fulfill this use-case as far as I can tell. If the developer knows in advance whether to request nesting or not, they could also just not apply I see two ways to add this feature:
This means the group will be nested if there's only an old state. I guess you could have other values, like Alternatively: const viewTransition = document.startViewTransition(updateCallback);
const transitionDetails = await transition.ready;
if (transitionDetails.groups.foo && !transitionDetails.groups.foo.new) {
transitionDetails.groups.root.append(transitionDetails.groups.foo);
} …which is an imperative API that lets you trigger the nesting of groups. |
I like the declarative way since there is a defined point when the DOM structure is finalized. The transform animation the UA sets on the group is dependent on this nesting so we don't want it to change once the animations have started. Just one thought, there was a feature request early on for developers to be able to animate snapshots of the old DOM while we're waiting for the new DOM to load. The idea being that exit animations don't need to block on new content loading. And we considered accomplishing this by creating the pseudo DOM, with only |
I'm glad to see the discussion about this concern going on. I believe my concern would resolve if there was ability to set condition for making groups in the nested view transitions. Comparing named view transition groups by JS manually, that was mentioned by #8528 (comment), is feeling like a bit of high computational costs to run, and still difficult to control if the page state with updated DOM was unpredictable (e.g. MPA in general, SPA with the unstable state of a page). Actually |
Can I create a named group only when elements with the same name defined by the
view-transition-name
property, exist in both the before and after transition?I am trying to figure out how to include an element with marked as
view-transition-name: xxx
, that exists only in one side of transition, in::view-transition-group(root)
instead of::view-transition-group(xxx)
.I'm developing the tool to create HTML-based presentation slides called Marp, that have slide transitions support powered by View Transitions API. All of transition effects for slides are defined as CSS animations working in
::view-transition-group(root)
, and the slide author can make a morphing animation like PowerPoint Morph and Keynote Magic Move, by marking morphable elements between 2 slides byview-transition-name
CSS property.In this case, even if there is an element named with
view-transition-name: xxx
on only one side of the transition, a corresponding::view-transition-group(xxx)
with a simple fade effect is generated. However, this element is rendered in the same position before and after the transition due to the specification of View Transitions API. If the::view-transition-group(root)
has a flashy effect, may feel this element like out of place.The following slide example sets various transitions when navigating, and
view-transition-name
property to the inline code in page 2 and 3. (Source)example.mov
If there is no
view-transition-name
property on one side of the transition, I want to make that element belong to::view-transition-group(root)
. (In above example, transitions when navigating 1 ↔︎ 2 and 3 ↔︎ 4)I tried to use JavaScript to generate
::view-transition-group()
only when the same namedview-transition-name
property exists on both sides of the transition, but it didn't work out in the end.I also thought using
::view-transition-old(*):only-child
and::view-transition-new(*):only-child
CSS selectors as already explained in https://drafts.csswg.org/css-view-transitions-1/#example-387929ce. However, in situations where this selector can be used,::view-transition-group()
has already been generated. It is not possible to change that group to belong to::view-transition-group(root)
by CSS.I apologize if this already is achievable. But if not, are there any insights about controlling whether make a particular group when the element named by
view-transition-name
property was there only in one side of the transition? (e.g. Adding an optional argument todocument.startViewTransition
to set constraints about generating the view transition group)The text was updated successfully, but these errors were encountered: