@halobear/lazyload
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@halobear/lazyload

lozyload.js rewrite by ts

安装

yarn add @halobear/lazyload
# or
npm install @halobear/lazyload

使用

<div data-src="images/1.jpg" class="lazyload"></div>
<img
  src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQYV2N49+7dfwAJYgPK+tLRowAAAABJRU5ErkJggg=="
  data-src="images/2.jpg"
  class="lazyload"
/>
import Lazyload from '@halobear/lazyload'

typeof Images: NodeListOf<HTMLImageElement | HTMLElement> | undefined

type LazyloadSetting = {
  src: string,
  srcset: string,
  selector: string,
  root: null,
  rootMargin: string,
  threshold: number,
}

// 初始化加载
const lazyload = new Lazyload(images: Images, setting: LazyloadSetting)

// 销毁
lazyload.destroy()

// 强制加载
lazyload.loadAndDestory()

Readme

Keywords

none

Package Sidebar

Install

npm i @halobear/lazyload

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

16.2 kB

Total Files

7

Last publish

Collaborators

  • wtwei
  • luzhongk
  • v_yan_v