Re: [csswg-drafts] [css-values-4] Abandon mix()? (#9343)

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 `@keyframes foo { from { prop: start; } to { prop: end; }}`, then you could write `prop: mix(start; end; X%)` and get the exact same value.

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 `transform` that requires layout info (such as `translate(50%)`) but also triggers matrix interpolation (which can only express fixed pixel values). Anything else it did was secondary; there's some minor usefulness in being able to get an interpolated value without having to interpolate manually, but that wasn't the point.

> We could allow it to be specified for anything, but resolve it by computed-value time if there's no interpolation behavior.

Good news: the spec already says *exactly* this:

> If the two `<declaration-value>`s in mix() are interpolable (without using mix() itself) as values for the property in which it is specified, the computed value of mix() is the result of interpolating these two values to the progress given by the `<percentage>`. Otherwise, the computed value of mix() is the mix() functional notation itself with its `<percentage>` computed and both `<declaration-value>`s computed as values for this property.

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 `transform-mix()`?), if we'd prefer to do that instead of having a generic facility. As you point out, a specialized function allows for more specific control when necessary (like specifying color space in the color mixing functions). I don't have a strong opinion either way, actually.

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


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

Received on Friday, 15 September 2023 09:00:15 UTC