object-fit-polyfill icon indicating copy to clipboard operation
object-fit-polyfill copied to clipboard

Fix invisible image

Open MasGaNo opened this issue 8 years ago • 2 comments

Hi!

I create this new PR because, I see that for pictures that are not displayed in the DOMTree, the polyfill doesn't work correctly and so when I display for the first time the picture, it's not correctly configured until I resize the screen.

Feel free to improve this part, I think we can do it better.

Thank you.

MasGaNo avatar Jun 06 '17 15:06 MasGaNo

Hey hey! Quick question - what's the specific use-case for non-visible elements? I can think of 2 off the top of my head (lazy-loading and carousels) - but I'm not totally convinced that the polyfill should be opinionated enough to handle those cases out of the box.

Rather than the polyfill listening for or polling for a visibility change (which can get extremely expensive, esp. in the case of lazy-loading galleries for example), I would rather see the responsbility of polyfilling images that change visibility be on the developer rather than on the polyfill.

See https://github.com/constancecchen/object-fit-polyfill/issues/21#issuecomment-293693668 for what I think is a much more performant solution - image libs that affect visibility should fire events (most carousel libs do every time a slide changes, for example), and devs should hook onto those events for polyfilling.

cee-chen avatar Jun 22 '17 08:06 cee-chen

Fix for img element in picture element:

picture { width : 100%; height : 100%; display: flex; }

52eins avatar Feb 15 '19 07:02 52eins