frodo-lazy-img
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Lazy-Img

this is only a simple react lazy loading component. As the main purpose is to learn how to use npm publish.

In case someone may accidently dependent on the poor lib. Here is the Github where he/she can report bugs or just to tell the unsatisfactory :D

Install

npm install --save lazy-laod

Usage

Simply import and use it as a <img />

offsetcould be set to tell how many pixels to load image before the actual position.

import LazyLoad from 'lazy-load';
import React from 'react';
 
export default () => {
    return (
        <LazyLoad src={/**/} offset={200} />
    );
}

API

Properties Description
src the src of the image
offset if set, this will set a pilot to tell the browser to prefetch
retry retry times when the loading is fail.
onLoadStart expose a method to invoke when image start, success, fail to load.
onLoadSuccess
onLoadFailed

Browser Supporting

This component doesn't support IE, Safari and Oepera for the missing of IntersectionObserver API

I added an option to deal with those browser which doesn't support IntersectionObserver API

Readme

Keywords

Package Sidebar

Install

npm i frodo-lazy-img

Weekly Downloads

12

Version

1.0.3

License

ISC

Unpacked Size

231 kB

Total Files

12

Last publish

Collaborators

  • lyz1996