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

jh-virtual-scroll

v0.0.3

Published

virtual-scroll

Downloads

40

Readme

jh-virtual-scroll 虚拟滚动

用于解决大量数据渲染时,dom 节点过多导致渲染性能降低甚至页面'假死'的情况。兼容原生 js/jQuery/Vue/React/Angular 等。

Installation

webpack

$ npm install jh-virtual-scroll
import 'jh-virtual-scroll.js';

browser

<script src="http://zhkumsg.gitee.io/jh-virtual-scroll/lib/index.js"></script>

Example

live demo

<ul id="main"></ul>
var jhVScroller = new JhVirtualScroll(document.querySelector('#main'), {
	fetch: function() {
		// return datas
	},
	skeleton: function() {
		// return dom
	},
	render: function(data) {
		// return dom
	},
});

引入jh-virtual-scroll后将在全局作用上挂载JhVirtualScroll对象,实例化语句如下

new JhVirtualScroll(el, options,count);

可接受三个参数,依次代表需要监听的元素、渲染配置以及视图外显示多少个元素。

| 参数 | 类型 | 说明 | | :-----: | :----: | :-------------------------------------------------------------------: | | el | dom | 需要监听的元素 | | options | object | 渲染配置,包含三个 fetch、render 和 skeleton 三个属性,详见 options | | count | number | 可见区域外额外显示多少个元素,默认为 10 |

options

| 属性 | 类型 | 说明 | | :------: | :------: | :--------------------------------------------------------------------------------------------------------------------------------------------: | | fetch | function | 支持同步和 promise 返回,在运行过程中会多次调用该方法,用于接收分页数据(array),当返回数据为空数组或者 Promise.reject 时,认为已获取全部数据 | | render | function | 定义如何渲染每一项,接收参数 data 为当前渲染用到的数据,需要返回一个 dom 节点 | | skeleton | function | 定义如何渲染骨架,当快速滚动时避免数据没渲染导致空白,需要返回一个默认的 dom 节点 |

Attributes & Events

  • vnodeList 当前实例下渲染核心属性,包含每一项节点的 dom、尺寸以及偏移信息等。非特殊情况下,该属性应为只读属性。

  • onReload 当前实例的重置函数,可清空内容,重新进行初始化,接收一个回调方法。