bigbite / macy.js

http://macyjs.com/
MIT License
1.28k stars 156 forks source link

Incompatibility with LazySizes? #57

Closed JayHoltslander closed 4 years ago

JayHoltslander commented 5 years ago

Trying to use this with LazySizes and most of the images (but not all) on the page load at 1-2px height only. What am I missing here?

jrmd commented 4 years ago

Hi @JayHoltslander

Sorry for the late response, although I have never used LazySizes I imagine it would be possible to get this to work if there is an event listener you can use one the image is loaded in, so you can call recalculate on the macy instance.

Once macy has calculated the image height it will ignore it for any recalculations, this was added so content loaded via ajax wouldnt cause the entire macy instance to recalculate. The only time macy will do a full recalculate by itself is on page resize. So you will manually have to call recalculate

Hope this helps.

JayHoltslander commented 4 years ago

I use LazySizes a lot since Google has gone on record as officially recommending it.