npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lazy-img-react

v1.0.0

Published

Simple, efficient and easy-to-use lazy load image react component. (supports region scroll)

Downloads

9

Readme

lazy-img-react npm

Simple, efficient and easy-to-use lazy load image react component. (supports region scroll)

简单、高效、易用的图片懒加载react组件。(支持区域滚动懒加载)

Demo

Browser compatibility

Supports IE9+ / Android4.4+ / etc. ES5 enviroment.

支持PC/移动设备所有兼容ES5环境的浏览器。

Installation

You can install lazy-img-react from npm.

你可以从npm安装lazy-img-react组件。

npm install lazy-img-react --save

Usage

Import lazy-img-react.

引入lazy-img-react组件。

import LazyImg from 'lazy-img-react';

Just use it like a normal img tag.

像普通的img标签一样使用即可。

<LazyImg width="200" height="200" alt="xxx" src="../image.jpg" />

Wrap with LazyImg.Container in the region scroll mode. And associate with ref of the container component.

区域滚动时需使用LazyImg.Container容器组件包裹,并与容器组件ref关联。

const LazyContainer = LazyImg.Container;
<LazyContainer ref={el => this.container = el}>
  <LazyImg src="../image1.jpg" container={this.container} />
  <LazyImg src="../image2.jpg" container={this.container} />
  ...
</LazyContainer>

Options

src: PropTypes.string

Image src. default: ''

图片路径。默认为:''

placeholder: PropTypes.string

The placeholder image src. It will show before the image loads or scrolls into view. default: A block with 'background:#cccccc'

图片加载前的占位图路径。默认为:以#cccccc为底色的区块

offset: PropTypes.number

Lazy load leads offset. default: 0

加载偏移提前量。默认为:0

container: PropTypes.object

Reference of the container. Don't forget this param when in region scroll mode. default: null

区域滚动时图片所属的容器ref引用。默认为:null

testing

git clone [email protected]:jackyr/lazy-img-react.git
cd lazy-img-react
npm install
npm start

License

MIT