Re: [csswg-drafts] [css-view-transitions-2] Conditionally choose participating elements when onscreen in both DOM states (#9354)

+1 to optimizing performance by skipping transitions on elements that are not visible within the viewport in either the old or new DOM. 

As a developer writing Javascript and CSS, one way I might try to approach this optimization on the Javascript side could be to use [Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) to keep track of when elements are visible in the viewport. Then, if they are visible, conditionally add a `view-transition-name` to them. 

But I realize a shortcoming of that approach is that it only captures element visibility in the old DOM, and misses elements that are not presently visible but may become visible after a transition (such as for a long list of items on a page where items below the fold may need to transition to appear higher up on the page when the list is re-ordered). Those would not receive a `view-transition-name` in the old DOM and thus may not be animated during a transition. 


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


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

Received on Tuesday, 3 October 2023 22:10:21 UTC