Re: [csswg-drafts] [css-values-5] [css-overflow-4]How does `line-clamp` transition from `<integer>` to `auto` or `none`? (#10502)

> Can we have line-clamp add a unit like lh (e.g. `lc`)? Making it always calculable as a length would solve the problem of animation calculations?

I don't think that's possible. There's questions like what does `1.5lc` mean, or does `0lc` include the initial margin, or what if you have `6lc` and you only have 4 lines, or what happens when you set `height: 3lc` on a grid with multiple columns with differently sized text, or what if you use `lc` on width rather than height...

But more fundamentally, for a `lc` value to resolve to a pixel length, you need layout (i.e. you need to figure out which content goes in every line, how to place floats, how to collapse margins...), and the style resolution (which includes resolving units to pixels) needs to happen before layout. Otherwise, you might get into dependency cycles which could be impossible to resolve.

> Rather than the lines appearing or disappearing into the hidden overflow, you could also set line-clamp: auto on .item (so it's enabled on both sides of the transition) to change the number of clamped lines as the height animates. (Note that this could cause jank, since every frame would need a separate layout.) This doesn't seem to work currently in my implementation in Chromium, but it's probably a simple layout caching bug.

Sorry to disappoint, but after looking a lot more into how `interpolate-size` and `calc-size` work, I realized that this behavior isn't what would automatically fall out of the current spec text – and that is also why it didn't work in the Chromium implementation. I guess it would not be impossible to define `line-clamp: auto` in a way that it would work, but you would need multiple layouts for each frame, which might make the performance of this unacceptable to browsers.

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


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

Received on Tuesday, 22 October 2024 19:37:27 UTC