Skip to content

lazySizes.autoSizer.checkElems() should trigger reassessment of bg image implemented by object-fit #648

Closed
@Hlsgs

Description

I am using LS with parent-fit, object-fit and respimg. Some interesting "issues" arose when cloning an element that contains an image already handled by the plugins:

If cloning and appending said element somewhere where it has different dimensions via CSS, the auto-sizes functionality does not do it's job out of the box. Since LS auto-detects elements added to the DOM, I wondered what exactly in the cloned nodes was stopping that, so I removed the lazyloaded class and readded lazyload. Modern browsers started working as expected, but IE11 din not(It's stuck with the background src it had before cloning).

var source = $(this);
var content = source.children().not('.lazysizes-display-clone').clone();
content.find('img').removeClass('lazyloaded').addClass('lazyload');
stage.find('#team-info-wrapper').empty().append( content );

My next idea was adding lazySizes.autoSizer.checkElems() after appending the element, and, again, modern browsers cool, IE bad.

I then did a quick check without object-fit, and everything was fine in IE, so I guess it's with object-fit that the logic stops.

I'm thinking that both readding the lazyload class and calling lazySizes.autoSizer.checkElems() should, in turn, trigger a reassessment of the bg image implemented by the object-fit.

I hope this all made sense!

Cheers and much kudos for this excellent stuff. It's become an essential part of my toolkit!

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions