-
Notifications
You must be signed in to change notification settings - Fork 672
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-images-4] Allow transitions between different types within stripes()
#8622
Comments
Flex isn't interpolable with length in Grid because they cause trigger different layout behaviors, and figuring out a way to mix their effects with continuity would have been way too complicated for the benefit we'd get from it. In stripes() flexes are much simpler (they just turn into lengths with a relatively trivial transform), so in theory they could be interpolable. You can't do it naively with a calc(), tho. Flex values are context-dependent, not just on the container size but also on the sum of all flex values in use in the context. A
We could fix both of these! For (1) we could normalize the flex sum to a fixed value (1fr?) at computed-value time. (This is probably a good idea anyway, since the currently-allowed interpolation of flex segments still suffers from this problem - These two fixes would give us a reasonable interpolation behavior, but we'd still have to deal with the mixing of flex/length issue, and define what happened in Grid if you mixed them. (Right now it's a syntax error, so we don't have to deal with it.) |
Can you elaborate on that? I would have hoped we'd be able to come up with a general solution for this issue. Though I'm currently not deep enough into the layout algorithm differences to make a reasonable point here.
Yes, I didn't explicitly mention that but my examples already take both into consideration.
Thanks for pointing that out! Normalizing them sounds reasonable to me. Though I wonder whether there might be use cases in which authors want to mix different sums of flex values to achieve a certain effect. If we normalize the sums, this isn't possible, but if we don't normalize, both can be achieved.
That sounds totally reasonable. Though that's also already defined in the spec. by you and even shown in an example. Or is there still something missing?
It could still be defined as a syntax error in Grid for the time being and be discussed separately if needed. But as I said, ideally we could come up with a general solution for that. Basically, the algorithm is already defined in a way to make interpolation between flex and other values possible. I.e. first substract any non-flex values from the total width and then split the remaining width according to the sizes of the flex values. Sebastian |
The Grid layout algorithm invokes different algos if you have flexible lengths vs if you don't. There's not much to elaborate on, it just does different things.
The effect is really weird; if they want to do something weird they can do it by hand by adding more intermediate values. I don't think there's even a moderate use-case for the behavior to be done intentionally.
Ahahaha, no, I just forgot I'd done that. Okay, good.
Not... easily. Hm. I suppose I could reuse the machinery that %s do, where it's a syntax error to mix %s with a type if the % doesn't resolve to that type. |
That's precisely what I was thinking: in So we could have |
Interpolation of |
stripes()
stripes()
Of course! I am too focused on Backgrounds 4 lately. Sorry! Sebastian |
The example you gave earlier, transitioning from I think it's time to discuss this on a call. The proposed resolution is to adopt Tab's suggestions from this issue and from #8140. They are:
I explicitly excluded the issue around mixing flex and length values in Grid, as it seems to deserve a separate discussion. Sebastian |
This kinda reminds me of aspect ratios (#4953). If we don't compute |
If a So |
No need to invoke log transitions to fix the behavior here. We want linear transitions, and that has a straightforward meaning, it's just that the actual flex values used are context-specific (they depend on the sum of flexes around them). Normalizing a >1 sum to =1 fixes that issue so flexes on either side of the transition can be directly compared/transitioned sensibly, and it basically matches how we deal with flexes elsewhere. |
I'm not sure how I missed this comment, but yes, that makes perfect sense, @Loirooriol. Each flex computes to |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
The CSS Working Group just discussed
The full IRC log of that discussion<fantasai> -> https://github.com//issues/8622#issuecomment-1758136484<fantasai> TabAtkins: Currently, in stripes() you can write widths as length, percentage, or flex <fantasai> ... we didn't have interpolation behavior for between flex and lengths <fantasai> ... but in this context, the flex definition is very straightforward and can be expressed in terms of percentages and lengths <fantasai> ... so my proposal was that each flex in a stripes function will compute to a particular expression <fantasai> ... which makes it into a <length-percentage> <TabAtkins> max(0, 100% - sum-of-percents - sum-of-fixed) * flex value / max(1, sum-of-flexes) <fantasai> ... and then you can transition that with all the other length-percentages just fine <fantasai> fantasai: Sounds fine <Rossen_> fantasai: makes sense. Do we store as computed value? <fantasai> ... or do we compute through to <length-percentage> only when interpolating <fantasai> TabAtkins: It's best for authors to leave fr's as they are, unless they need to convert for an interpolation <flackr> +1 <fantasai> +1 <fantasai> s/store as/store fr as/ <fantasai> TabAtkins: [explains the formula] <fantasai> flackr: I like converting just-in-time <fantasai> ... we do this with other types when interpolating <fantasai> RESOLVED: fr values in stripes() convert to max(0, 100% - sum-of-percents - sum-of-fixed) * flex value / max(1, sum-of-flexes) (a <length-percentage>) when needed for interpolation |
stripes()
stripes()
In #8140 @fantasai changed the computed value of
stripes()
to sayThe reason behind that was to make it work for inherited properties.
Though that seems to come at the cost of not being able to transition between values.
At the same time, CSS Grid defines this:
Both result in disallowing transitions between values of different types.
In #8163 I provided an example of how those types could be computed. That would allow transitioning between them and animating them.
Taken from that issue:
Possible answer: With a total width of 60px, the transition would be from
stripes(#000 10px, #111 20px, transparent 30px)
tostripes(#222 20px, #333 40px, transparent 0px)
. For 120px total width it would be fromstripes(#000 10px, #111 20px, transparent 90px)
tostripes(#222 40px, #333 80px, transparent 0px)
.Also
stripes(#111 calc(5px + 5fr), #222 calc(10px + 10fr))
could be made valid. With a total length of 60px again, it would be equivalent tostripes(#111 calc(5px + 15px), #222 calc(10px + 30px))
. And assuming a total width of 120px, it would be the same asstripes(#111 calc(5px + 35px), #222 calc(10px + 70px))
.Sebastian
The text was updated successfully, but these errors were encountered: