# dload-lazyload

> Srcset Lazyload plugin

Latest version **1.3.7** (published 2019-08-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install dload-lazyload
pnpm add dload-lazyload
yarn add dload-lazyload
bun add dload-lazyload
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.7 |
| Published | 2019-08-30 |
| First published | 2018-11-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 20.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Author | Diederik Eenschooten |
| Maintainers | diederikeenschooten |
| Keywords | lazy-load, npm, reveal, animation, performance, src-set |

## Links

- npm: https://www.npmjs.com/package/dload-lazyload
- Repository: https://github.com/diederikeen/dload-lazyload
- Homepage: https://github.com/diederikeen/dload-lazyload#readme
- Issues: https://github.com/diederikeen/dload-lazyload/issues
- npm.io page: https://npm.io/package/dload-lazyload

## Dependencies (2)

- [npm-run-all](https://npm.io/package/npm-run-all.md) ^4.1.5
- [webpack-merge](https://npm.io/package/webpack-merge.md) ^4.2.2

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.3.7 (latest) — 2019-08-30
- 1.3.6 — 2019-08-30
- 1.3.5 — 2019-08-30
- 1.3.4 — 2019-08-30
- 1.3.3 — 2019-08-30
- 1.3.2 — 2019-08-30
- 1.3.1 — 2019-04-25
- 1.3.0 — 2019-04-25
- 1.2.0 — 2019-02-25
- 1.1.9 — 2019-01-17
- 1.1.8 — 2019-01-17
- 1.1.7 — 2019-01-17
- 1.1.6 — 2018-12-10
- 1.1.5 — 2018-12-07
- 1.1.4 — 2018-11-20
- … 15 more at https://npm.io/package/dload-lazyload/versions

## README

# Dload-lazy-load

Dload is a lazy-load plugin for elements and images. It's easily adjustable and easy in use

----
## Installation
    npm i dload-lazyload

### In your js.
    import dload from 'dload-lazyload';
    
    document.addEventListener('DOMContentLoaded', () => {
      dload();
    });

Or with custom settings

    import dload from 'dload-lazyload';
    
    document.addEventListener('DOMContentLoaded', () => {
      dload({
        className: 'your-custom-class',
        loadedClass: 'classname-when-in-view',
        singleSource: true,
      });
    });
    
### Custom options
| Option        | Description   | Default Value |  Custom value type |
| ------------- |:-------------| -------------- | ------------- | 
| className     | Class name of elements that will be  lazy loaded | lazy-load | `string` |
| loadedClass   | Class name that will be added once in viewport |  lazy-loaded | `string` |
| singleSource  | Boolean to define a single source instead of multi sources | false | `bool` |


### In your scss.

    @import 'dload-lazyload/src/styles/variables';
    @import 'dload-lazyload/src/styles/dload-lazyload';


### Your HTML markup

#### Basic multisource markup

    <figure 
        class="lazy-load"
        data-srcset='{
            "default":"./assets/img/img.jpg",
            "defaultRetina": "./assets/img/imgRetina.jpg",
          }'
      >

But there are some other images avaiable to. For optimal performance for mobile/tablet we've added a couple more sources, which you can devide by a `,`.

In the following example you can see all of the possible `options`.

    <figure
        class="lazy-load"
        data-srcset='{
          "base": "https://example.com/dir/to/img/folder/",
          "default": "image1.jpg",
          "defaultRetina": "image1@retina.jpg",
          "mobile": "image2.jpg",
          "mobileRetina": "image2@retina.jpg",
          "tablet": "image3.jpg",
          "tabletRetina": "image3@retina.jpg"
        }'
      >

#### Basic singleSource markup

    <figure 
        class="lazy-load"
        data-srcset='./assets/img/img.jpg'
      >

And now you're ready to go.


## Transition classes

For transition classes I've decided to go with `reveal`.

#### Example:

    <figure 
      class="lazy-load reveal reveal--up"
      data-srcset='{
        "default":"./assets/img/img.jpg",
        "defaultRetina": "./assets/img/imgRetina.jpg",
      }'
    >

There are multiple pre made classes for you to use and change.

* `reveal--fade` (can be used with any other class)
* `reveal--up` (transforms bottom to top)
* `reveal--left` (transforms right to left)
* `reveal--right` (transforms left to right)


There are some variables that you're able to change: Simply reset the variable to your liking.

* `$dload-transition: cubic-bezier(0.165, 0.84, 0.44, 1) !default`;
* `$dload-transition-speed: 600ms !default;`
* `$dload-transform-value: 40px !default;`
* `$dload-delays: 100 300 600 900 !default;`


### Delays

If you want delays on your animations you can either set a class like `reveal--500`. This class is generated by the `$delays` variable. Simply add or remove values to create extra classes.


#### Example:

    <figure 
      class="lazy-load reveal reveal--up reveal--600"
      data-srcset='{
        "default":"./assets/img/img.jpg",
        "defaultRetina": "./assets/img/imgRetina.jpg",
      }'
    >

If you want a random delay you can add the class `reveal--random` and a random valye between 0 and 500ms will be set on the element

#### Example:

    <figure 
      class="lazy-load reveal reveal--up reveal--random"
      data-srcset='{
        "default":"./assets/img/img.jpg",
        "defaultRetina": "./assets/img/imgRetina.jpg",
      }'
    >

---
_Source: https://npm.io/package/dload-lazyload · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
