Skip to content

Instantly share code, notes, and snippets.

@aaronsummers
Last active December 6, 2019 15:21
Show Gist options
  • Select an option

  • Save aaronsummers/19a6f8b49a4c24095fdd7f1a516b73bf to your computer and use it in GitHub Desktop.

Select an option

Save aaronsummers/19a6f8b49a4c24095fdd7f1a516b73bf to your computer and use it in GitHub Desktop.
Lazy loading slick slider images with b-lazy

when using blazy to lazy load images with slick slider use this callback to revalidate blazy

HTML:

<div class="blazy-carousel">
  <div class="c-lazy" data-src="images/slide.jpg"></div>
</div>

JS

// Carousel Lazyload
   var bLazy_carousel = new Blazy({ 
       container: '.blazy-carousel', // Default is window
       selector: '.c-lazy',
       loadInvisible: true
   });
   // Revalidate on change
   $('.blazy-carousel').on('afterChange', function(event, slick, direction){
     bLazy_carousel.revalidate();
   });
@thibka
Copy link

thibka commented Dec 6, 2019

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment