GithubHelp home page GithubHelp logo

fjandin / react-virtual-list Goto Github PK

View Code? Open in Web Editor NEW

This project forked from developerdizzle/react-virtual-list

0.0 2.0 0.0 436 KB

Super simple virtualized list React component

Home Page: http://developerdizzle.github.io/react-virtual-list/

License: MIT License

JavaScript 100.00%

react-virtual-list's Introduction

Super simple virtualized list React component

Check out the demo here

This React component allows you to display a large list of fixed-height items in your document, while only rendering the items visible in the viewport. This allows a large list to be rendered with much fewer DOM elements.

Installation

You can use NPM to install react-virtual-list:

$ npm install react-virtual-list --save

Usage

The ./dist/VirtualList.js module exports a single React component.

var VirtualList = require('react-virtual-list');

JSX

<VirtualList items={this.props.items} renderItem={this.renderItem} itemHeight={this.props.itemHeight} />

Properties

  • items the full array of list items. Only the visible subset of these will be rendered.
  • renderItem a function to render a single item, passed as argument item. Must return a single React element (React.createElement(...))
  • itemHeight the height in pixels of a single item. You must have a CSS rule that sets the height of each list item to this value.
  • container the scrollable element that contains the list. Defaults to window. Use this if you have a list inside an element with overflow: scroll.
  • tagName the tagName for the root element that surrounds the items rendered by renderItem. Defaults to div. Use this if you want to render a list with ul and li, or any other elements.
  • scrollDelay the delay in milliseconds after scroll to recalculate. Defaults to 0. Can be used to throttle recalculation.
  • itemBuffer the number of items that should be rendered before and after the visible viewport. Defaults to 0.

Any other properties set on VirtualList, such as className, will be reflected on the component's root element.

Functions

  • visibleItems the currently visible array of items. Can be used to figure out which items are in the viewport. Eg: var items = this.refs.list.visibleItems()

Example Usage

Check out https://github.com/developerdizzle/react-virtual-list/blob/gh-pages/App.jsx for the example used in the demo.

Tests

Use npm test to run the tests using jasmine-node. Currently only the math calculations are tested. Hoping to add some DOM tests as well.

To Do

react-virtual-list's People

Contributors

developerdizzle avatar jordaaash avatar

Watchers

 avatar  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.