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

antd-virtual-select

v1.1.2

Published

Long list optimization antd select component

Downloads

966

Readme

开始

npm i antd-virtual-select

功能特性

  1. 使用 antd Select dropdownRender 方法自定义原组件下拉列表部分
  2. 虚拟滚动渲染,只渲染可视区列表,滚动动态加载其他列表,支持上万条数据渲染
  3. 对自定义列表项绑定原 Select 组件的各项方法和回调函数支持
  4. 同步使用 antd 组件下拉列表样式
  5. 同 antd select api
  6. 设置 mode={Select.SECRET_COMBOBOX_MODE_DO_NOT_USE} 属性可成为支持大数据渲染的 AutoComplete 组件

在线 demo

更多 antd 长列表渲染性能问题讨论可查看 antd 官方 issue 3789

antd 4.0 Select 组件已支持虚拟列表(ie11+),此组件基于 antd 3.x,可用于 ie9 浏览器

使用

基本使用同 antd Select,只是使用 SuperSelect 代替 Select

import SuperSelect from '@nuo-common/cloudjz-virtual-select';

const Option = SuperSelect.Option;

const Example = () => {
  const children = [];

  for (let i = 0; i < 100000; i++) {
    children.push(
      <Option value={i + ''} key={i}>
        {i}
      </Option>
    );
  }

  return (
    <SuperSelect
      showSearch
      // mode="multiple"
      // onChange={onChange}
      // onSearch={onSearch}
      // onSelect={onSelect}
      // optionHeight={50}
    >
      {children}
    </SuperSelect>
  );
};

Feature

  • Support tens of thousands of data scrolling smoothly
  • Same as ant api, easy to use
  • Simple to implement, can be modified according to needs
  • Support for direct use in antd Form
  • set an optionHeight props to allow the height of the Option to be dynamically controlled

Code

  • Use the antd Select dropdownRender method to customize the drop-down list content, rendering only about dozens of data in the viewport
  • Calculate the scrolling distance of the list, re-render when scrolling about the height of the visible area, reduce the number of renderings and improve performance
  • Represents methods such as antd Select onChange to implement the same api usage and callback parameter return

demo

Change Log

2020-10-19

2020-06-09

  • fix:
    1. 修复滚动一定高度后搜索,搜索输入情况后数据列表显示空白问题
    2. 展开下拉列表默认滚动到当前选中项位置

2020-07-15

  • fix:

    1. 修复添加 dropdownClassName 属性无效问题
  • feat:

    1. 设置 mode={Select.SECRET_COMBOBOX_MODE_DO_NOT_USE} 属性可成为支持大数据渲染的 AutoComplete 组件

2020-07-20