# tw-lazy-loading

> this is for picture lazy loading

Latest version **1.3.42** (published 2017-12-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install tw-lazy-loading
pnpm add tw-lazy-loading
yarn add tw-lazy-loading
bun add tw-lazy-loading
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.42 |
| Published | 2017-12-04 |
| First published | 2017-11-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | huritian |
| Maintainers | huxin |
| Keywords | lazy, loading, js |

## Links

- npm: https://www.npmjs.com/package/tw-lazy-loading
- npm.io page: https://npm.io/package/tw-lazy-loading

## Dependencies (2)

- [cross-env](https://npm.io/package/cross-env.md) ^5.1.1
- [html-webpack-plugin](https://npm.io/package/html-webpack-plugin.md) ^2.30.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.3.42 (latest) — 2017-12-04
- 1.3.41 — 2017-12-04
- 1.3.4 — 2017-12-04
- 1.3.3 — 2017-12-03
- 1.3.22 — 2017-12-03
- 1.3.21 — 2017-12-03
- 1.3.2 — 2017-12-03
- 1.3.1 — 2017-12-03
- 1.2.9 — 2017-12-02
- 1.2.8 — 2017-12-02
- 1.2.7 — 2017-12-02
- 1.2.6 — 2017-12-02
- 1.2.5 — 2017-12-02
- 1.2.4 — 2017-12-02
- 1.2.3 — 2017-12-01
- … 26 more at https://npm.io/package/tw-lazy-loading/versions

## README

# 项目名称
tw-lazy-loading
图片懒加载(只针对垂直滚动的情况)

# example
可以下载浏览./example/richText.html
启动示例命令行
npm run dev

# 下载安装
npm install tw-lazy-loading

# 使用
```javascript
> import LazyLoad from 'tw-lazy-loading'
let LazyLoad = new LazyLoad(option)
```
>标签引入
```javascript
<script src="./node_modules/tw-lazy-loading/dist/index.js"></script>
let LazyLoad = new window.LazyLoad(option)
```
>监听的img处，添加class值
```javascript
<img class="tw-laazy-load">
```
>引入dist包下面的index.js
>需要使用处参数选项

```javascript
option = {
  minH // 选填，number 屏幕滚动到什么位置时调用图片清晰函数，minH必须为大于等于0的整数
  blurParame // 选填，array 图片模糊OSS参数[el1, el2],参数取值范围为1~50，length <= 2
  container // 选填， 标签容器，在什么标签内，使用本方法，如document.getElemmentById(ID),vue开发情况下，不能使用refs
  delay // 选填 number 屏幕滚动间隔多少毫秒执行一次图片转化为清晰图片的函数, delay必须大于0
}
```
> 异步加载懒加载图片数据时需要在异步函数成功后调用
```javascript
LazyLoad.initPic()
```

# 暴露的方法
1、LazyLoad.handleBlur(content) 给富文本添加OSS图片模糊的后缀
> @parma content {string} 富文本
> @return content

2、LazyLoad.initPic()
> 页面调用接口，增加了页面的图片数量时，调用此接口，修改图片容器大小，没有返回值

# 注意事项
> 如果DOM的IMG标签处，自定义了OSS的模糊句柄，那么需要在option内部传入blurParame
> 富文本中懒加载图片的class是tw_className，在需要监听处的img的class属性上添加tw_className

---
_Source: https://npm.io/package/tw-lazy-loading · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
