3.0.8 • Published 6 months ago

lesca-image-onload v3.0.8

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

NPM React React React React React NPM

Why use it?

a listener for load images of DOM.

Live Demo

Installation

npm install lesca-image-onload --save

Usage

import ImageOnload from 'lesca-image-onload';

new ImageOnload()
  .load(containerRef.current, {
    hideBeforeLoaded: true,
    onUpdate: (e) => {
      const { loaded, total } = e;
      const percent = (loaded / total) * 100; // 0~9x
    },
  })
  .then((e) => {
    const { loaded, total } = e;
    const percent = (loaded / total) * 100; // 100
  });

Development

Methods

methoddescriptionreturn
.constructor()new classclass
.load(dom:DOM, options:object)Load HTML node imagesPromise

options

Propertiesdescriptionreturn
onUpdate:functioncallback for each image onload{ url:string, index:int, total:int, loaded:int }
hideBeforeLoaded:booleanset root node style display to 'none'default = true

Features

  • add React hook
  • maintain if necessary
3.0.8

6 months ago

3.0.7

7 months ago

3.0.6

7 months ago

3.0.5

7 months ago

3.0.4

9 months ago

3.0.3

1 year ago

3.0.2

1 year ago

3.0.1

2 years ago

3.0.0

2 years ago

2.1.0

2 years ago

2.0.2

3 years ago

2.0.1

3 years ago

1.0.4

3 years ago

2.0.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago