Installations
npm install @gem-mine/rc-lazy-image
Developer Guide
BETA
Typescript
No
Module System
CommonJS
Node Version
8.10.0
NPM Version
5.6.0
Score
71.9
Supply Chain
92.5
Quality
81.8
Maintenance
100
Vulnerability
99.6
License
Releases
Unable to fetch releases
Love this project? Help keep it running — sponsor us today! 🚀
Download Statistics
Total Downloads
1,358
Last Day
1
Last Week
2
Last Month
12
Last Year
131
Bundle Size
9.14 kB
Minified
3.44 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.1.1
Package Id
@gem-mine/rc-lazy-image@0.1.1
Unpacked Size
25.77 kB
Size
7.65 kB
File Count
5
NPM Version
5.6.0
Node Version
8.10.0
Total Downloads
Cumulative downloads
Total Downloads
1,358
Last day
0%
1
Compared to previous day
Last week
-33.3%
2
Compared to previous week
Last month
100%
12
Compared to previous month
Last year
-34.2%
131
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
34
babel-clibabel-eslintbabel-plugin-add-module-exportsbabel-plugin-importbabel-plugin-transform-decorators-legacybabel-plugin-transform-es3-member-expression-literalsbabel-plugin-transform-es3-property-literalsbabel-plugin-transform-proto-to-assignbabel-plugin-transform-runtimebabel-preset-es2015babel-preset-reactbabel-preset-stage-0eslinteslint-config-reacteslint-config-standardeslint-config-standard-reacteslint-loadereslint-plugin-importeslint-plugin-nodeeslint-plugin-promiseeslint-plugin-reacteslint-plugin-standardfs-extramd-tools-climd-tools-theme-component-reactpostcss-color-rgba-fallbackpre-commitprop-typesreactreact-domreact-routershxstylelintstylelint-config-standard
Versions
rc-lazy-image
图片懒加载组件,提供异步加载等相关功能。
Usage
1import React from 'react'; 2import ReactDOM from 'react-dom'; 3import Image from '@gem-mine/rc-lazy-image'; 4ReactDOM.render(<Image src='xxx.jpg' />, container);
基本用法
1import Image from '@gem-mine/rc-lazy-image' 2 3const props = { 4 width: 200, 5 height: 200, 6} 7 8class App extends React.Component { 9 10 render() { 11 return ( 12 <div> 13 <Image {...props} 14 src='//gcdncs.101.com/v0.1/static/fish/script/swfupload/a801236bjw1ez812gy3g8j20rs0rs0z5.jpg' /> 15 <Image {...props} 16 src='//gcdncs.101.com/err.jpg' /> 17 </div> 18 ); 19 } 20} 21 22ReactDOM.render(<App />, mountNode);
事件
1import Image from '@gem-mine/rc-lazy-image' 2 3const props = { 4 threshold: 500, 5 appear: () => { 6 console.log('threshold trigger') 7 } 8}; 9 10ReactDOM.render( 11 <div> 12 <Image 13 {...props} 14 src={'//gcdncs.101.com/v0.1/static/fish/script/swfupload/a801236bjw1ez812gy3g8j20rs0rs0z5.jpg'} 15 /> 16 </div>, 17 mountNode, 18); 19
API
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
threshold | 指定距离底部多少距离时触发加载 | Number | 0 |
event | 指定触发事件,默认为'scroll' | String | scroll |
container | 指定容器,默认为window | React.Node | window |
parent | 可以指定动画效果作用于元素的哪个父级元素 | String | Number | - |
appear | 元素出现在可视窗口时触发appear钩子函数 | Function | null |
load | 元素图片的加载完后触发load钩子函数 | Function | null |
error | 图片加载出错时触发error钩子函数 | Function | null |
node_type | 指定生成的节点类型,默认为'img' | String | img |
placeholder | 占位元素,除了支持普通的图片外,还支持react组件 | String | React.Node | 默认占位图 |
fork from react-lazyimg-component
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No security vulnerabilities found.