lazyLoad
IntersectionObserver-based lazy loading. Images load only when they enter the viewport. Falls back to immediate load in browsers without IntersectionObserver.
Import
import { lazyLoad } from '@andresclua/sliderkit-plugins' Usage
// Use data-src instead of src on images
new Slider('#el', {
plugins: [lazyLoad({ rootMargin: '200px' })],
}) HTML
<div class="c--slider-a__slide" data-slide>
<img data-src="/photo-large.jpg" alt="..." />
</div> Options
| Option | Type | Default | Description |
|---|---|---|---|
selector | string | '[data-src]' | CSS selector for lazy elements. |
rootMargin | string | '200px' | IntersectionObserver rootMargin — how early to start loading. |