1
I’m using Lazysizes to load images progressively. https://github.com/aFarkas/lazysizes
That’s the style of my project
<div class="image-wrap">
<img class="lazyload" src="">
</div>
When images are loading, the IMG tag gains a new class lazyloading and upon completion of loading, it is replaced by the lazyloaded
What I would like to do is, put or remove a class in DIV.image-wrap, class-based .lazyloading of the IMG element.
<script src="https://afarkas.github.io/lazysizes/lazysizes.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="image-wrap">
<a href="#">
<img class="lazyload" data-src="http://lorempixel.com/150/150">
</a>
</div>
<div class="image-wrap">
<a href="#">
<img class="lazyload" data-src="http://lorempixel.com/150/150/sports/">
</a>
</div>
<div class="image-wrap">
<a href="#">
<img class="lazyload" data-src="http://lorempixel.com/150/150/nature/">
</a>
</div>
<div class="image-wrap">
<a href="#">
<img class="lazyload" data-src="http://lorempixel.com/150/150/cats/">
</a>
</div>
<div class="image-wrap">
<a href="#">
<img class="lazyload" data-src="http://lorempixel.com/150/150/business/">
</a>
</div>
<div class="image-wrap">
<a href="#">
<img class="lazyload" data-src="http://lorempixel.com/150/150/city/">
</a>
</div>
<div class="image-wrap">
<a href="#">
<img class="lazyload" data-src="http://lorempixel.com/150/150/people/">
</a>
</div>
</div>
could put the code that is using the lazysizes?
– Karl Zillner
you should probably put something like
$(this).parents("div.image-wrap").removeClass("image-wrap");
but to give the correct answer you need to insert this into your code– Karl Zillner
@Karlzillner I just call the standard class "lazyload" of lib Lazysizes.min.js and everything works as intended.
– John Quimera
I’ll put an example here in the stack.
– John Quimera
@Karlzillner posted the code.
– John Quimera
As so "based on the class . lazyloading"?
– Sam
@dvd With lazysizes images are loaded one by one. The default class in the IMG element is lazyload and when an image is loading the class lazyloading enters into action next to it, and when the loading of that image is completed, the class lazyloading is replaced by the class lazyloaded what I want now is to use add/remove a class from div.Parent based on classes that go live in IMG.
– John Quimera
@dvd When the class lazyloading is active in the IMG element, I want another class to be active in the DIV of which the IMG element is inside, and when the lazyloading class is no longer, that the same happens with the div class Parent.
– John Quimera