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 🙏

© 2025 – Pkg Stats / Ryan Hefner

tw-lazy-loading

v1.3.42

Published

this is for picture lazy loading

Readme

项目名称

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

example

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

下载安装

npm install tw-lazy-loading

使用

> import LazyLoad from 'tw-lazy-loading'
let LazyLoad = new LazyLoad(option)

标签引入

<script src="./node_modules/tw-lazy-loading/dist/index.js"></script>
let LazyLoad = new window.LazyLoad(option)

监听的img处,添加class值

<img class="tw-laazy-load">

引入dist包下面的index.js 需要使用处参数选项

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

异步加载懒加载图片数据时需要在异步函数成功后调用

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