Code Monkey home page Code Monkey logo

antd-virtual-select's Introduction

开始

npm i antd-virtual-select

功能特性

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

更多 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}
    >
      {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

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-01-06

  • feat:
    1. 更新构建配置

2020-01-20

  • fix:
    1. 修复 Option 组件添加 style={xxx} 样式无效问题

2020-03-02

  • fix:
    1. 修复异步加载数据时下拉列表高度固定 100px 问题
    2. onDropdownVisibleChange 回调函数未触发问题

2020-03-17

  • fix:
    1. 输入筛选条件直接 blur 后下拉列表没有重置为全部列表

antd-virtual-select's People

Contributors

iblq avatar dependabot[bot] avatar yaokailun avatar pengtikui avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.