-
Notifications
You must be signed in to change notification settings - Fork 719
[css-values] Abandon mix()? #9343
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
Comments
Abandon, or narrow in scope? What happens if this is limited to properties that can have clearly defined interpolations for transitioning/animations/etc? Are there other issues we would need to address? |
Abandon in its current form. :-) If we make
Yes. We could allow it to be specified for anything, but resolve it by computed-value time if there's no interpolation behavior. Examples:
And then we allow |
The intention of mix() is that it represented exactly the behavior that you get from animating between the two input values; that is, if you could write This had exactly one purpose: to allow representing the computed value of an animated property that cannot be fully resolved at computed-value time, like a
Good news: the spec already says exactly this:
So outside of the very few cases that can't be represented at computed-value time, mix() already disappears at computed-value time. This shouldn't require any changes to computed values for any properties that wouldn't already require this kind of thing anyway. That said, we do have several functions which are essentially specialized mix() versions: color-mix(), palette-mix(), cross-fade(). It is possible for us to just add more specialized functions as needed (a |
Are you sure? Wouldn't the current spec cause e.g. the computed value of
So we end up with
The good thing about That said, if we still really want EDIT: Formatting. |
I suppose I just didn't properly handle the case where values genuinely aren't interpolable, like for
Yeah that's valid. Let's ask the larger WG about this; I'm happy to go in either direction. (But if we drop |
I guess discrete interpolation is still an interpolation, so And can the broken " |
@tabatkins I think #6429 made |
Ah and also I already do specify that it's invalid if the values aren't interpolable. |
Ah, OK. I think that was it. See also the IRC discussion in the first post. These comments reinforced (or caused?) my misunderstanding:
|
…e bits without changing meaning. #9343
I added some more examples calling out these cases. But your point about the specialized functions being a useful type is still valid, so let's still talk about this in the group. |
For now, we've kicked mix() out of Values 4 and put it into the Values 5 draft (alongside a more general treatment of mixing stuff, as discussed in #6245). |
I suggested moving it to L5 in #6753 (comment), but @fantasai said
|
Yeah, but that's been an issue for years, so we're not making things worse in the interim. ^_^ |
We've added |
I think the goal of
These involve different tradeoffs and different design decisions. I suspect 1 is easier to implement (?) and from the author's perspective, 1 covers their use cases just fine. 2 does make for a smaller API surface, but its benefits are largely internal. From an author perspective, it’s entirely unclear why --untyped-custom-property: mix(...);
property: something var(--untyped-custom-property), something else;
I wonder if a reasonable MVP would be to only ship the
This already makes the current workarounds a lot easier, doesn’t have warts like having to be the whole value of a property, and can even be generalized in a limited way like so: @keyframes mix-helper {
from { background: var(--from);
to { background: var(--to);
}
.foo {
--from: yellow;
--to: linear-gradient(in oklch, yellow, oklch(.5 .2 180));
other-property: mix(background at 30% of mix-helper);
} |
The "extract a value from particular progress along a keyframe'd animation" idea is completely unrelated to mix(); it was discussed around the same time, but it's not in any way a "mixing" function. I'm annoyed it got folded into the spec; it needs to be a completely different function. I suggest ignoring it; I'm pinging Elika right now about killing it (and potentially reviving it in a dedicated function instead). Ignoring that usage, what use-cases do you think mix() covers that aren't covered by existing values and the proposed |
In aspect-ratio: mix(50%, 1, 9); /* 3 */ If I use I'm not sure whether a |
Yes, specifically at 50% it can be simplified as a basic geometric mean, but otherwise it's a weighted geometric mean and you need something like the formulas above. |
Sure, but (a) the interpolated result is completely expressible as a number, and (b) you can reproduce it by hand with If we think that exposing a convenient shorthand for logarithmic interpolation would be useful, we can do so, but there's nothing requiring us to do so like the other cases we've added a *-mix() for. (Well, |
The CSS Working Group just discussed
The full IRC log of that discussion |
From #6245 (comment):
(cc @smfr)
If my understanding is correct,
mix()
as currently defined is asking for way too much for not nearly enough benefit.This would indeed require that any computed value that we currently store in a space-efficient manner now needs to deal with the possibility of being a function instead, which then needs to be interpreted further used-value time (@bfgeek). This is probably a non-starter, but it also doesn't seem that necessary. E.g. do we really need to be able to represent
display: mix(inline; block; 50%)
as a computed value when no meaningful mix between inline/block exists (I hope)?The current path we're on elsewhere in CSS, with type-specific mix functions (
color-mix
,font-palette-mix
) seems way more sensible:mix()
.So ideally we should just abandon
mix()
. We can probably find other ways of doing everything we want in #6245, e.g. extend all typed*-mix()
functions with the capability of pulling progress from a named timeline, and things like that.The text was updated successfully, but these errors were encountered: