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

virtuallist-react

v0.0.5

Published

This is a virtual list component based on react

Downloads

9

Readme

Introduce

NPM JavaScript Style Guide

这是一个基于 react 所开发的虚拟列表组件。

Install

npm install virtuallist-react --save

Gitee address

https://gitee.com/transee/virtuallist-react

Usage

import React from "react";
import ReactDOM from "react-dom";
import VirtualList from 'virtuallist-react';
const data = new Array(5_000_000).fill(0).map((item) => Math.random());
ReactDOM.render(
  <div>
    <VirtualList
      options={{
        width: "100%",
        height: "100%",
        count: data.length,
        itemWidth: "100%",
        itemHeight: 200,
        delay: 30,
        appendNum: 10,
        loading: (
          <div style={{ background: "red", height: "100%" }}>读取中......</div>
        ),
        renderItem: ({ index, style }) => (
          <div key={data[index]} style={style}>
            <img
              alt={index}
              height={200}
              src={
                "https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png?" +
                Math.random()
              }
            />
            data: {data[index]}, Row: #{index}
          </div>
        ),
      }}
    />
  </div>,
  document.getElementById("root")
);

Props

interface VirtualListProps {
    options: {
        count: number;//数据总数,目前仅支持数组长度
        width: string | number;//整个容器宽度
        height: string | number;//整个容器高度
        itemWidth: string|number;//每一行的宽度,建议100%
        itemHeight: number;//每一行的高度
        loading?: JSX.Element;//最底部追加的提示元素
        appendNum?:number;//每次页面展示多少个是根据每行高度和容器高度来计算的,这里可以追加多一些,这样的话滚动起来看着更加顺畅。
        bothAppend?:number;//上下都追加多少项目,使得上下滚动都更加流畅些,提前请求。
        renderItem: Function;//每一项渲染时的回调函数,在这里定义每行具体的内容展示
        delay:number;//其实是一个节流函数,防止滚动触发过快导致资源反复加载,浪费大量性能。可以根据自己需要控制
        dom?: number;//支持传入一个ref,拿到容器dom,可以对容器位置等进行控制。举个例子:虚拟滚动跟传统的直铺最大的用户体验问题在于没有浏览器在带的crtl+f搜索,那么父级处理完搜索跳转到第几行,这里传入ref,拿到了dom以后,就可以在对应的操作里让容器滚动到指定的地方,实现crtl+f搜索。该特性在0.0.4开始支持。
    }
}