-
Notifications
You must be signed in to change notification settings - Fork 669
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-values] Abandon mix()? #9343
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 "<s" in the spec be fixed? |
@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<dael> TabAtkins: First off, to clarify. Since issue was filled mix() gained a new syntax. We're not talking about that. This is about dropping original feature for mix(). It was intended to let us represent values that couldn't be written as computed but do interpolate<dael> TabAtkins: Since then we added sufficient specialized functions to values 5 to handle all cases we know where this happens. Only a handful of cases that needed the generic interpolation. <dael> TabAtkins: So, I believe we can drop the generic interpolator and stick with the specific ones that handle each thing that needs special behavior <dael> florian: And it did not represent things that are not interpolable? <dael> TabAtkins: Correct, it was invalid syntax <dael> fantasai: Two reasons mix was added. One was for these interp that you can't show intermediary value. Other was create syntax to allow authors to represent an interpolation of a value between two breakpoints in a MQ. It's not that the intermediary can't be represented but it's because you want a range depending on another calc <miriam> q+ <dael> fantasai: That's what mix was originally for. Since then, TabAtkins and I decided it should be kicked from level 4. But the other function of mix where you can take a whole property value and interpolate between it and another value based on how far you are in a 800px window <dael> florian: And you could represented it but not well? <astearns> ack miriam <dael> fantasai: You could, but now that there's calc-mix you can represent. But if you have something like descrete keywords you can't unless there's an existing mix value <dael> miriam: You've basically answered my question. <dael> TabAtkins: They cover the case for the types they're meant for. There's a bunch of types like keywords that don't have a mix function <dael> miriam: That use case feels useful to me <dael> fantasai: I think there are reasons to want something like mix. I don't think we want to impl as is. Reasonable to resolve not in L4 but seems reasonable to explore <dael> TabAtkins: Also resolve that we're not intending mix to represent intermediate values would be good. But intent that it's useful for authors to say somewhere on this path is good. Good to resolve that we're not keeping mix to rep intermediate values <dael> astearns: Prop: We will drop mix from L4. Specifically, we don't want to use it for the generic representation of interpolated values but we may in a future level come up with something like mix to express the interpolation itself <dael> fantasai: 2 resolutions. Drop mix from Values L4. Second is: Keep exploring mix for interpolation use cases but not for representing a single interpolated value <TabAtkins> proposed: we're not keeping mix() *for the purpose of representing intermediate values*. keeping it for *authors wanting to interpolate arbitrary things* is still on the table <dael> astearns: First part, drop mix from Values 4. Obj? <dael> RESOLVED: Drop mix() from Values 4 <dael> astearns: Second is we will never use mix to represent a single interpolated value but may have something like it for expressing the whole interpolation <dael> fantasai: It shouldn't be the only way to represent the value <dael> RESOLVED: We will not rely on mix() to represent a single interpolated value but may have something like it for expressing the whole interpolation |
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: