I'm trying to make a lightbox that needs an animation that starts from a thumbnail to a fullscreen image.
On the thumbnail state, the image will be kept inside a container with a fixed aspect ratio (say, 3:2). Every image on the gallery will have to fit within this allotted space, covering its entire surface (usually object-fit: cover).
On the fullscreen state, the container will expand to something like 100vw:100vh, and the image can expand (or even contract, the case for some unusually tall image) to fit within (object-fit: contain).
The <img> must always keep its aspect ratio untouched (on both states, and during the animation).
I can animate the container's width and height (they have absolute values).
But object-fit animation is discrete.
Here is a pen coding both states and container's animation: https://codepen.io/rslemos/pen/PoNMymR (to see the animation, one should remove the expanded class from the container element).
Is there any CSS trick to emulate object-fit using linear properties?
EDIT
During the animation, the image itself - I mean, the surface covered by the bitmap, not <img> element, which could be bigger or smaller than <img> in any direction - should morph from its initial to its final size.
I've also edited the pen to show the initial state when the container aspect ratio (width:height) is < 1 (using the same image, with aspect ratio > 1).