lesca-image-onload
TypeScript icon, indicating that this package has built-in type declarations

3.0.9 • Public • Published

NPM React React React React React NPM

Why use it?

a listener for load images of DOM.

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

method description return
.constructor() new class class
.load(dom:DOM, options:object) Load HTML node images Promise

options

Properties description return
onUpdate:function callback for each image onload { url:string, index:int, total:int, loaded:int }
hideBeforeLoaded:boolean set root node style display to 'none' default = true

Features

  • add React hook
  • maintain if necessary

Readme

Keywords

Package Sidebar

Install

npm i lesca-image-onload

Weekly Downloads

8

Version

3.0.9

License

MIT

Unpacked Size

1.13 MB

Total Files

49

Last publish

Collaborators

  • jameshsu1125