Add imports to head
<link rel="stylesheet" href="lazyload.css">
<script src="lazyload.js"></script>You can use it with NPM
- JS: just uncomment export in on end of
lazyload.js, then you can import it in some module - SCSS: instead of using
cssstylesheet, you can importscss
Using lazyload instance, you can call add function, to initialize lazy-loading elements.
add- Add elements to be lazy-loadedselector- query selector of lazy-loaded elementsdistance- distance (in px, from bottom of view), where selected element(s) should start loading (when lazy-loaded element has margin, the margin is also the part of element - animation may start earlier than you expect)direction- direction from where element(s) appear: bottom/left/right