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

lazyloadermini

v1.0.4

Published

a mini lazyloader

Downloads

8

Readme

Lazyloader mini

环境依赖

  • node
  • window

API说明

lazyloader.lazy(el, pEl, distance, fn);

/**
 * @param el 需要触发loader的element的id
 * @param pEl 需要触发loader的element的父级/祖级id
 * @param distance 距离触发的大小,即缓冲区高度/宽度
 * @param fn callback 回调函数
 */

lazyloader.lazy("mini", "pre", 300, this.init);

lazyloader.remove(el);

lazyloader.remove("mini");

使用例子

  1. mini lazyloader主要是垂直方向的赖加载
  2. window 环境使用,直接引入lazyloader1.js
<div id="pre">
  <div class="midd">
    <div class="test"></div><div class="test"></div><div class="test"></div>
    <div class="test"></div><div class="test"></div><div class="test"></div>
    <div id="mini">
      <p>2333333</p>
    </div>
  </div>
</div>

<script src="../lib/lazyloader1.js"></script>
<script type="text/javascript">
  var init = function () {
    setTimeout(function() {
      var items = document.getElementById('mini').parentElement;
      var li = document.createElement('div');
      li.className = 'test';
      li.style.width = '100%';
      li.style.height = '300px';
      li.style.background = 'yellow';
      li.style.marginTop = '10px';
      items.appendChild(li);
    }, 100);
  }
  // window.lazyloader('mini', 200, init);.lazy('mini', 200, init);
  window.lazyloader.lazy('mini', 'pre', 200, init);
  setTimeout(function() {
    // 5S之后移除监听器
    window.lazyloader.remove('mini');
  }, 5000);
</script>
  1. import 导入
import lazyloader from "lazyloadermini";

created() {
    lazyloader.lazy("mini", 'pre', 300, this.init);
}

destroyed() {
  lazyloader.lazy('mini');
}

init() {
    console.log('hello lazyloadermini');
}

目录结构描述

├── lib // the main code
│ ├── lazyloader.js // v1.0.0
│ ├── lazyloader0.js // v1.0.1
│ ├── lazyloader1.js // v1.0.3
├── test // test
│ └── test.html // test.html
├── README.md // readme
├── package.json // package resource

v1.0.1 版本内容更新

  • [x] 参考js-cookie重构
  • [x] 提供lazy,remove(removeEventListener)

v1.0.3 版本

  • [x] 提供parentElement,nowElement的相互结合使用lazyloader
  • [x] 完善remove方法,移除EventListener