Re: [csswg-drafts] [css-view-transitions-2] Support View Transitions on a DOM subtree (#9890)

The CSS Working Group just discussed `[css-view-transitions-2] Support View Transitions on a DOM subtree`.

<details><summary>The full IRC log of that discussion</summary>
&lt;khush> https://docs.google.com/presentation/d/1yi1ynyk8cidWPY6L6Io4Al0IS6rQ8lGjQSZIZtgdPlw/edit?usp=sharing<br>
&lt;TabAtkins> khush: This is about an extension we're epxloring for VT<br>
&lt;TabAtkins> khush: other than cross-doc, this is one of the most requested features from authors<br>
&lt;TabAtkins> khush: fundanemtnal characteristic of how VT work today is they're global<br>
&lt;TabAtkins> khush: you're doing full-page changes in single-page apps<br>
&lt;TabAtkins> khush: as a result, you have all these limitations<br>
&lt;TabAtkins> khush: if a third-party widget is doing a dom change, it can't do VT without affecting your whole doc<br>
&lt;TabAtkins> khush: during VT you'll get a stacking content that draws on top of whole doc<br>
&lt;TabAtkins> khush: while your callback is running to update the DOM, all animations in the page will stop<br>
&lt;TabAtkins> khush: common scenario is a you click a button, widget comes up, shows a spinner while it loads. you'll notice the spinner pause now<br>
&lt;TabAtkins> khush: third issue is document becomes non-interactive<br>
&lt;TabAtkins> khush: if you have multiple stories all wanting to load up a VT, they're all noninteractive<br>
&lt;TabAtkins> khush: and finally you only get one transition at a time<br>
&lt;TabAtkins> khush: have to manually queue them<br>
&lt;TabAtkins> khush: but conceptually these are all independent<br>
&lt;TabAtkins> khush: today, to hack around this you have to insert an iframe. two iframes cant VT independently, at least theoretically. (but in chrome it depends on whether your iframe is OOP or not, and it's super heavyweight and bad)<br>
&lt;TabAtkins> khush: so hope is to address all fo these<br>
&lt;TabAtkins> khush: [shows simple dom]<br>
&lt;TabAtkins> khush: outer element wants to be part of the root transitions<br>
&lt;TabAtkins> khush: inner only wants to transition in the scoped-root<br>
&lt;TabAtkins> khush: so like if you ahve a page with a list of stories, you can have a root transition where all stories are sliding in, and scoped is each story animating itself internally<br>
&lt;TabAtkins> khush: so new proposal is view-transition-scope, saying this subtree establishes a scope, and scoped VTs can occur in it<br>
&lt;TabAtkins> khush: on the script side you grab a ref to the DOM you want, and use the normal API.<br>
&lt;TabAtkins> khush: so instead of only being able to start a VT form the Document, you can put it on any element<br>
&lt;TabAtkins> khush: [shows pseudo DOM]<br>
&lt;bramus> q+<br>
&lt;TabAtkins> khush: what w'ere trying to design now is what the node tree looks like<br>
&lt;TabAtkins> khush: idea is, if you have a VT tree rooted at doc righ tnow, you'll have a similar one rooted at the scoping element<br>
&lt;TabAtkins> khush: Here, the inner can contribute to the root or to the scoped VT<br>
&lt;TabAtkins> khush: We generate an image that can plug into the ancestor's transition<br>
&lt;TabAtkins> khush: the scoped root has "inner" as one group, for child elements participating in it<br>
&lt;TabAtkins> khush: So v-t-scope property says names that only exist in this node participate only in the scoped subtree's VT<br>
&lt;TabAtkins> khush: Today, if you use an iframe to do the nested VT, this is what th enode tree looks like<br>
&lt;TabAtkins> khush: so it's consistent<br>
&lt;TabAtkins> khush: some challenges<br>
&lt;TabAtkins> khush: isolating vt names, this is what v-t-scope is about<br>
&lt;TabAtkins> khush: It would be awkward to have a single leement painting at multiple spots<br>
&lt;astearns> q+ to ask about iframes as an alternative to this<br>
&lt;TabAtkins> khush: weird to have it display at multiple places in the screen<br>
&lt;TabAtkins> khush: so the names are isolated both syntactically, but also fundamentally, you can only participate in your nearest scoped ancestor's transition<br>
&lt;TabAtkins> khush: also, you can async update the DOM. a lot of frameworks authors integrate with don't support a sync update to the DOM.<br>
&lt;TabAtkins> khush: if possible we'd like to make that still work in scoped transitions<br>
&lt;TabAtkins> khush: so while you're updating the tree, browser has to display *something*. thinking is we want to display the old screenshot<br>
&lt;TabAtkins> khush: sort of a content-visiblity mode - as soon as the brower captures a screenshot, it keeps displaying that while the tree is updated underneath<br>
&lt;TabAtkins> khush: if your dom tree is in an intermediate state, you probably dont' wnat that to change the size of the element. so probably some sort of containment is needed. more research here.<br>
&lt;TabAtkins> khush: last challenge is about resizing. what happens when your scoped element's box resizes? image doesn't match the original size it was captured at, but it has to fit in the resized box<br>
&lt;TabAtkins> khush: some ideas - we should probably generate the pseudo-dom early<br>
&lt;TabAtkins> khush: today, the first frame fo the pseudo-dom matches exactly what th eold content looked like<br>
&lt;TabAtkins> khush: so continuing tha tmodel, we probably want the old appearance to immediatley show up in a pseudo<br>
&lt;TabAtkins> khush: also right now when we capture an element, we put all the box decorations (background, shadow, etc) in the image<br>
&lt;TabAtkins> khush: but here we're treating the scoped root's image as only its contents<br>
&lt;TabAtkins> khush: it's more like the scoped root's decorations are part of its ancestors context, not itself, so it can resize nicely<br>
&lt;TabAtkins> vmpstr: for v-t-scope Bramus suggested it be a container type instead of a new property<br>
&lt;TabAtkins> vmpstr: not set on a particular approach yet<br>
&lt;miriam> ack bramus<br>
&lt;emilio> q+<br>
&lt;TabAtkins> bramus: yes, this is #1 author request<br>
&lt;TabAtkins> bramus: second is name of the property. we have anchor-scope and timeline-scope already, i don't think name fits with these. more about isolation or containment.<br>
&lt;miriam> ack astearns<br>
&lt;Zakim> astearns, you wanted to ask about iframes as an alternative to this<br>
&lt;TabAtkins> astearns: in the tree slide, you mentioned this is the same structure you'd get in an iframe<br>
&lt;fantasai> so you're suggesting view-transition-container instead of view-transition-scope?<br>
&lt;TabAtkins> astearns: is that just sufficient? use iframes if you want scoped elements<br>
&lt;TabAtkins> khush: with iframes, the element resizes... we took a shortcut so if the iframe resizes we just skip the transition<br>
&lt;bramus> qq+<br>
&lt;TabAtkins> khush: the other thing is that a lot of other problems i mentioned, even with same-process iframes, impl internally is not able to support it<br>
&lt;TabAtkins> khush: so this is more like - if people start using iframes they'll still run into a lot of problems, so we need to solve them properly anyway<br>
&lt;TabAtkins> khush: what we're seeing is that people are just avoiding this use-case despite really wanting it<br>
&lt;TabAtkins> khush: [describes a problem with iframe impl today]<br>
&lt;miriam> ack fantasai<br>
&lt;Zakim> fantasai, you wanted to react to astearns to say this is presentational, shouldn't force weird document structures<br>
&lt;flackr> q+<br>
&lt;TabAtkins> fantasai: this is a presentational effect, it shouldn't force us to restructure the entire document relationship<br>
&lt;bramus> https://front-end.social/@bramus/111800601352108818<br>
&lt;miriam> ack bramus<br>
&lt;Zakim> bramus, you wanted to react to astearns<br>
&lt;TabAtkins> bramus: Here's an example I made, a header that expands and contracts as you scroll the page<br>
&lt;TabAtkins> bramus: if you were forcing author to put the header into an iframe wouldn't work<br>
&lt;TabAtkins> bramus: like the back button is part of the header<br>
&lt;miriam> ack emilio<br>
&lt;TabAtkins> emilio: so you'rea dding this to Element (or HTMLElement?)<br>
&lt;TabAtkins> emilio: several restrictions - needs to be a paint container, or something<br>
&lt;TabAtkins> emilio: any restrictions on the element that you call the API  on? the scope element?<br>
&lt;TabAtkins> emilio: Another question is, how do you handle dom mutations?<br>
&lt;TabAtkins> emilio: Like if the dom moves around do you skip the transition, or do you just keep animating the pseudos as if they were there?<br>
&lt;TabAtkins> khush: for first q, there's an open questin about what sort of containment is needed<br>
&lt;TabAtkins> khush: today with VT, main one we landed on was if you put 'name' on osmething it needs to be a stacking context<br>
&lt;TabAtkins> khush: so we just applied those when you added a name (rather than requiring them for it be valid)<br>
&lt;TabAtkins> khush: we'd so similar here, add the restrictions if you do scope<br>
&lt;TabAtkins> khush: for second, today if you do transition on root and the element goes away, i think we skip the transition<br>
&lt;TabAtkins> khush: so this isn't a new problem<br>
&lt;TabAtkins> emilio: kinda is<br>
&lt;TabAtkins> emilio: iiuc, you animate its contents - or is it just any element insdie the scope?<br>
&lt;TabAtkins> khush: are you asking about when the scope root resizes?<br>
&lt;TabAtkins> emilio: so if you hav e scope root, and elements inside it animate, it seems like with this proposal you snapshot the elements that animate.<br>
&lt;TabAtkins> emilio: with documetn VT, you have the problem of element going away, but not with it moving elsewhere. it's always in the scope.<br>
&lt;TabAtkins> emilio: so what happens if the VT'd element moves out of its scope<br>
&lt;TabAtkins> vmpstr: the border-box vs contents is just the root itself (the scope root)<br>
&lt;TabAtkins> vmpstr: so you're asking if there's a VT'd node inside and it moves outside the scope<br>
&lt;TabAtkins> vmpstr: for the element inside the root, we'll capture the hwole thing (including decos)<br>
&lt;TabAtkins> vmpstr: if it moves out of the root, good question. we could treat it like it disappeared - fade it out? or just skip the transition<br>
&lt;TabAtkins> emilio: it's fine if it's TBD<br>
&lt;TabAtkins> noamr: the element moving causes it to dom-disconnect, makes sense to me that the transition gets skipped<br>
&lt;miriam> ack flackr<br>
&lt;TabAtkins> flackr: i think applying the restrictions we need at the point we start the transition is consistent with other animations things, like when we apply will-change<br>
&lt;TabAtkins> flackr: i think there's good answers for dom moving, but it's not as simple as skipping - if it's a child of the root you expect it to be able to move aorund<br>
&lt;TabAtkins> flackr: this proposal also shows how you do this with an imperative JS. is there a declarative equiv?<br>
&lt;TabAtkins> flackr: can I set some CSS rpoperty and have it start a scoped VT when I change the contents?<br>
&lt;TabAtkins> flackr: or what would that look like?<br>
&lt;TabAtkins> vmpstr: This is currently just an extension of the script API, easing the "only global" restriction.<br>
&lt;TabAtkins> vmpstr: the feature you're describing is a litle orthogonal, but could be enabled by this work<br>
&lt;TabAtkins> vmpstr: declaratively saying "this element animates when anything about it changes"<br>
&lt;TabAtkins> khush: this has been on the wishlist for a long time, someone pointed out changes on :hover<br>
&lt;TabAtkins> khush: fundamental issue is, when we realize you want to transition you've alread ymutated your dom<br>
&lt;TabAtkins> khush: we don't get an oppotunity to capture the old appearance<br>
&lt;TabAtkins> khush: that's why the JS version has you inform the browser to capture beforehand<br>
&lt;TabAtkins> khush: so that's why it's been harder to solve, but it's on our wishlist<br>
&lt;TabAtkins> bramus: i've also gotten the request from authors, but it's outside the scope<br>
&lt;TabAtkins> miriam: any resolution?<br>
&lt;TabAtkins> khush: no just feedback<br>
&lt;TabAtkins> miriam: okay, we're at lunchtime and there's no queue<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9890#issuecomment-1939468687 using your GitHub account


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

Received on Monday, 12 February 2024 20:01:51 UTC