-
Notifications
You must be signed in to change notification settings - Fork 682
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] Optimize no content change animations #9406
Comments
here's a demo that would benefit from the optimization https://codepen.io/argyleink/pen/VwBKjwj, there's multiple instances where the browser is capturing more than is needed. here's an example that's similar, but a little different https://codepen.io/argyleink/pen/PoxgOZz. there's a decent amount of javascript to manage whether or not to give a number a both scenarios, I'd love a property that let me articulate these cases. |
Big +1 to not capturing/animating unnecessarily.
Tacking that onto Something like this (🚲🛖):
I agree that a What is none of those two pseudos was generated at all? The snapshotted view would still need to be inserted into the pseudo tree (to have something visual on the screen), but since its not matched by any of the existing pseudos authors can not target it. |
This becomes very hard to define because we need a replaced element to show the snapshot. That said, the ambiguity with We could generate both the old/new pseudos with the following aspects:
|
+1 to optimizing the performance when there is no content change. I tested View Transitions in Chrome with a list of about 800 elements and found the performance to slow down a bit when starting transitions. Here's a fork of the Isotype style animation, with about 600 elements, to illustrate an extremely large number of elements being transitioned: https://codepen.io/bcole808/pen/VwqGoZm In this example, what I'm observing is that when clicking on one of the filters, there is a very long pause after the the pointer input occurs until the animation actually starts. Once the animation starts running, playback is pretty smooth. But the long pause before the animation starts makes it seem like there is a lot of work being done before it starts. Just showing the newly rendered element and applying a transition to the positioning (without a crossfade) is a common use case. So having a CSS property where developers can specify if there should be a crossfade from the old element to the new element sounds like a good idea. I agree that just tacking it onto |
I wonder if we can fold this into #10585. |
^ yea, |
It probably should since you would want to be able to mark either type of transition as optimized. Like so: |
Hmm this makes me think that perhaps this is indeed a separate feature, since you should be able to morph the borders and still not capture the contents. |
Is there a point in |
(Oops deleted your comment by mistake @Psychpsyo, sorry, don't know how to undo) |
Not sure if the original comment can be recovered, but here is a copy of it from my mails. @Psychpsyo wrote:
I was thinking that's what |
That is what @noamr said, not me. (I also don't remember what I commented.)
Overall: Now that I've said it like this, yes, two properties might make more sense. |
Probably because this doesn't add much as an optimization. If we're not capturing the old snapshot, capturing the box decorations only is cheap, and if they don't change they also wouldn't animate. Note also that the word I see this as 3 styles of transition:
We can also have
|
Given the resolution here: #10585 (comment), looks like we should have a standalone property for this to skip capturing the contents of the old element. Capturing styles is cheap and doesn't need to be optimized out. |
There are a couple of patterns where an element's position from the old state needs to be retained and animated but not its content. For example:
The cross-fade animation for these cases is an unnecessary perf hit: both because we captured pixels which weren't needed and then ran an animation using them. In case 1, the developer explicitly adds CSS to not display the old pixels. But the browser still has to do the work to capture and retain them until the transition ends.
A better way to do this would be a native API for the author to explicitly tell the browser that the content doesn't need to be animated. So instead of doing a cross-fade, just show the new content directly. Perhaps a new CSS property or addition to the existing
view-transition-name
likeview-transition-name: target no-content-animation
. If the developer says "no-content-animation", everything else works the same except no old image is captured. The old element contents are still removed from its parent snapshot. The pseudo-DOM won't generate a::view-transition-old
and there will be no fade-in animation on::view-transition-new
but rest of the UA CSS is the same.A few questions right now:
The text was updated successfully, but these errors were encountered: