Nothing Special   »   [go: up one dir, main page]

Skip to content
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] view-transition-group and the root element #10632

Closed
noamr opened this issue Jul 26, 2024 · 7 comments
Closed

[css-view-transitions-2] view-transition-group and the root element #10632

noamr opened this issue Jul 26, 2024 · 7 comments

Comments

@noamr
Copy link
Collaborator
noamr commented Jul 26, 2024

According to the resolution of #10334, it's possible to specify a custom ident as the view-transition-group, or e.g. nearest.
When the root element has a view-transition-name (which is root by default), nearest or view-transition-group: root might make it so that the root group would be the container instead of the global ::view-transition. This could often be unintended and not necessarily desired.

Alternatives:

  1. this is OK, root is just like everything else
  2. root is never a containing group
  3. nearest doesn't apply to the tree root, but it can be explicitly targeted (view-transition-group: root) or use contain
    (e.g. ::root { view-transition-group: contain })
@noamr
Copy link
Collaborator Author
noamr commented Jul 26, 2024

/cc @khushalsagar @vmpstr

@khushalsagar
Copy link
Member

The behaviour of picking root if the author says nearest seems fine to me. Because the initial value would be normal so that's what you should be using if you want ::view-transition. Am I missing a case?

@noamr
Copy link
Collaborator Author
noamr commented Jul 29, 2024

The behaviour of picking root if the author says nearest seems fine to me. Because the initial value would be normal so that's what you should be using if you want ::view-transition. Am I missing a case?

I'm thinking that in most cases nesting to root would be somewhat unexpected and redundant, because the root element clips the ::view-transition element anyway, so it's a bit of a double-clip.

So if someone has CSS like * { view-transition-group: nearest } to make everything nested, the behavior wrt root would be a bit strange. But I guess they could have something like :not(:host) { view-transition-group: contain } as an alternative.

It's not a big deal, but I think it's worth mentioning that nesting to the root element's group is a bit of a strange result and we should mind it and at least add a note.

@khushalsagar
Copy link
Member

I'm thinking that in most cases nesting to root would be somewhat unexpected and redundant, because the root element clips the ::view-transition element anyway, so it's a bit of a double-clip.

I didn't follow this. ::view-transition-group(root) is a child of ::view-transition.

container transform is a good example of where this would be helpful. It's an element -> root transition. If you want all children of the root to be clipped by it, you'd want to place them underneath the ::view-transition-group(root) pseudo.

@noamr
Copy link
Collaborator Author
noamr commented Jul 30, 2024

I'm thinking that in most cases nesting to root would be somewhat unexpected and redundant, because the root element clips the ::view-transition element anyway, so it's a bit of a double-clip.

I didn't follow this. ::view-transition-group(root) is a child of ::view-transition.

container transform is a good example of where this would be helpful. It's an element -> root transition. If you want all children of the root to be clipped by it, you'd want to place them underneath the ::view-transition-group(root) pseudo.

Yea I guess it makes sense from the point of view of the old element.
From the new element point of view, let's say the document element has a clip-path. That clip-path would clip the ::view-transition-group(foo) whether it's nested or not, because ::view-transition-group(foo) would be a descendant of :root regardless of it being a descendant of ::view-transition-group(root)

@khushalsagar
Copy link
Member

From the new element point of view, let's say the document element has a clip-path. That clip-path would clip the ::view-transition-group(foo) whether it's nested or not

That is not the case. The VT elements draw into their own stacking context and don't have root clips apply to them. Try this example:

<html>
<body>
  <style>
    :root {
      background: grey;
    }

    :root.new {
       clip-path: circle(80%);
    }

    .outside {
      position: fixed;
      bottom: 0px;
      height: 10px;
      width: 100vw;
      background: red;
      view-transition-name: outside
    }

    ::view-transition-group(outside) {
      animation-duration: 1s;
    }
  </style>
  <button onclick="doTransition()">Animate</button>
  <script>
    async function doTransition() {
      await document.startViewTransition(() => {
        document.documentElement.classList.toggle('old');
        document.documentElement.classList.toggle('new');
      }).finished;
    }
  </script>
  <div class="outside"></div>
</body>
</html>

The named element isn't clipped by the root's clip during the transition. This was an intentional choice, otherwise clips on the new Document root would immediately start applying to old snapshots.

@noamr
Copy link
Collaborator Author
noamr commented Aug 13, 2024

I think I'm satisfied with this, closing.

@noamr noamr closed this as completed Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants