Open chriskirknielsen opened 4 years ago
I have a use-case (slide deck speaker view) where it would be useful to scale elements so they fit a specific size. But that raised the question for me: is a transform
the right tool for the job? With both my use-case, and (I think) the iframe example, we likely need the actual element layout dimensions to change. Normally a transform doesn't impact the layout.
@mirisuzanne that sounds more like a job for View Transitions, don't you think?
In my case, I'm not trying to animate it from one size to another - just take a 'slide' element and scale it down to fit a smaller area.
The
scale()
function is useful and is used for lots of UI animations. However, sometimes, like in a "FLIP" context, it would be great to be able to specify a length directly, and let the browser figure out the scaling ratio.I am not certain what implications this would have, as I realise allowing lengths probably also means allowing an
auto
keyword in a scenario likescale(200px, auto)
(equivalent toscaleX(200px)
).Would the browser be able to compute the element's original size (say 300x150), parse
scaleX(150px)
, calculate the1/2
ratio and resolve toscale(0.5)
? Seems like a bit of a stretch but I've run into this a few times and have tried to reach for this but always ended up with a JS-powered solution, or giving up and simplifying it to a fixed scale.Aside from the FLIP technique, I've had the need for this when resizing an iframe I have no control over. I'd love to be able to say "fit this width and let the height be automatically determined", like
scaleX(100vw)
. (note: it's an iframe that is not responsive)In my title, I mention "absolute lengths" because I saw that percentages are planned to be accepted as
100% == 1
, so it seems that this proposal should only encompasspx
,em
,vw
, etc. Another way to phrase it would be "non-percent-based units" perhaps.Maybe I'm missing something crucial, but as I ran into this again today, so I figured I'd express the idea here!