An open API service indexing awesome lists of open source software.

https://github.com/dmitriyakkerman/lazy-img

Simple images lazy load module
https://github.com/dmitriyakkerman/lazy-img

lazy-load lazy-load-img lazy-loading

Last synced: 3 months ago
JSON representation

Simple images lazy load module

Awesome Lists containing this project

README

        

# lazy-img

Simple images lazy load module

**Usage**

1. Create image element with _**data-srс**_ attribute:

```html

```

2. Connect lazy-img.min.js.

```js

```

3 .Init plugin.

```js
LazyImg.init() // all 'img' tags with default "rootMargin" and "threshold"
LazyImg.init(".lazy") // specific img selector with default "rootMargin" and "threshold"
LazyImg.init(".lazy", "50px", 0.5) // specific img selector with specific "rootMargin" and "threshold"
```

**Params**

##### `param1`
Target element.

*Type:* String
*Required:* false
*Default:* 'img'

##### `param2`
RootMargin. Native Intersection Observer parameter for margin around the image element.

*Type:* String
*Required:* false
*Default:* '0px'

##### `param3`
Threshold. Native Intersection Observer parameter which indicates at what percentage of the image element visibility the lazy loading should be executed.

*Type:* Number
*Required:* false
*Default:* 0