8000 GitHub - devtoni/lazyloadimages-js: lazily load your images
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

devtoni/lazyloadimages-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Allows you to lazily load your images according to navigator compatibilities using API intersection observer or scroll event.

Usage

npm install --save lazyloading-images

Example

import lazyLoadHandler from 'lazyloading-images'

const images = document.querySelectorAll('img')
const options = {
  lazySrcAttribute: 'src',
  lazyLoadedClassName: 'loaded',
  intersectionObserverStrategy: true, //
  observerOptions: {
    root: document.querySelector('#scrollArea'),
    rootMargin: '0px',
    threshold: 1.0
  }
}

lazyLoadHandler().executeStrategy({ images, options })

API

lazySrcAttribute: String // The name of the data attribute, for example --> lazySrcAttribute: 'lazy' will be data-lazy,
lazyLoadedClassName: String // The className applied when your image is loaded,
intersectionObserverStrategy: Boolean, //enable or disable intersection observer strategy
observerOptions: {   // intersection observer options
  root: document.querySelector('#scrollArea'),
  rootMargin: '0px',
  threshold: 1.0
}

About

lazily load your images

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0