amplify icon indicating copy to clipboard operation
amplify copied to clipboard

Use transforms instead of altering widths

Open marcoms opened this issue 8 years ago • 3 comments
trafficstars

Would it be possible to use CSS transforms instead of setting max-width? Transforms should be more performant especially on low-end devices.

marcoms avatar Sep 18 '17 12:09 marcoms

Yes, I've been thinking about that but using vw with max-width allows the image to scale to a known max-width.

Using transform: scale() how would you make sure the expanded image is <= 100% of the window width since it purposely overflows its container? I believe more JavaScript would be necessary here but I'm open to suggestions.

charlestati avatar Sep 18 '17 13:09 charlestati

If it overflows container (e.g. page), it's useful to make it draggable

See images behavior on Medium

ColCh avatar Sep 20 '17 07:09 ColCh

Additional javascript would be required yes, although it shouldn't take too much to clamp the scale factor

To me the trade off would be worth it because afaik setting either width or max-width forces layout to run on each animated frame -- https://csstriggers.com/max-width, https://csstriggers.com/width

marcoms avatar Sep 20 '17 09:09 marcoms