1.0.18 • Published 1 year ago

lesca-react-onload v1.0.18

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

React React React React React NPM React NPM

Why use it?

Progress and timing provided for loading and animation.

Live Demo

codesandbox.io

Installation

npm install lesca-react-onload --save

Usage

import OnloadProvider from 'lesca-react-onload';
export default function () {

  const onStep = (e) => {
    const {loaded, total} = e;
    const percent = loaded / total * 100;
    console.log(percent) // get loading percent
  }

  const onload = (e) => {
    // all image loaded
  }

  return (
    <OnloadProvider hideBeforeLoaded onStep={onStep} onload={onload}>
      <img src='./myImage.jpg'>
      <div style={{ backgroundImage: 'url(./myBackgroundImage.jpg)' }} />
    </OnloadProvider>
  );
};

Properties

Propertiesdescriptiondefault
hideBeforeLoaded:booleanhide DOM before loadedtrue
onStep:functioncall when each image loaded
onload:functioncall when all image loaded

args

argsdescription
loaded:numbertarget image loaded number
total:numbertarget image total number
index:numbertarget image load index
url:stringtarget url

Features

  • maintain if necessary
1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.9

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.12

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.1

2 years ago