a listener of css background image onload
npm install lesca-image-onload






a listener for load images of DOM.
#### Live Demo
``sh`
npm install lesca-image-onload --save
`javascript
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
});
``
| method | description | return |
| :--------------------------------------------------------- | :-------------------: | ------: |
| .constructor() | new class | class |
| .load(dom:_DOM_, options:_object_) | Load HTML node images | Promise |
| 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 |
- add React hook
- maintain if necessary