Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

vunguyentuan/react-virtual-slider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Virtual Slider

A virtual slider for large dataset.

Join the chat at https://gitter.im/react-virtual-slider/Lobby

Travis npm package Coveralls License

GIF Demo

Features

  • Smooth animations - 60FPS dream 🌈
  • Independent style - just style it as you like
  • No scrollbar - yeah, you control the slider by calling goNext, goPrev, scrollTo methods
  • Render large dataset - no matter how much your data is, it's just works

Installation

Using npm:

$ npm install react-virtual-slider --save

Or yarn:

$ yarn add react-virtual-slider

Usage:

Basic Example

import React, { Component } from 'react'
import { render } from 'react-dom'

import VirtualSlider from 'react-virtual-slider'

const styles = {
  item: {
    width: 151,
    height: 188,
    display: 'inline-block'
  },
  container: {
    overflow: 'hidden',
  }
}

class Demo extends Component {
  renderItem = (index, key) => {
    return (
      <div key={key} style={styles.item}>
        {index}
      </div>
    )
  }

  handlePrev = () => {
    this.slider.goBack()
  }

  handleNext = () => {
    this.slider.goNext()
  }

  render() {
    return (
      <div>
        <VirtualSlider
          ref={slider => this.slider = slider}
          itemRenderer={this.renderItem}
          itemSize={151}
          length={50000}
          containerStyle={styles.container}
        />

        <button onClick={this.handlePrev}>Prev</button>
        <button onClick={this.handleNext}>Next</button>
      </div>
    )
  }
}

render(<Demo/>, document.querySelector('#demo'))

That's it! Simple :D

FAQ

Running Examples

In root folder:

	$ yarn install
	$ yarn start

Dependencies

React Virtual Slider has no dependencies. It has the only one peerDependencies: react

Reporting Issues

If believe you've found an issue, please report it along with any relevant details to reproduce it.

Asking for help

Please do not use the issue tracker for personal support requests. Instead, use Gitter or StackOverflow.

Contributions

Yes please! Feature requests / pull requests are welcome.