2.1.0 • Published 6 years ago

react-web-scroller v2.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

react-web-scroller

An react version of scroller inspired by iscroller.

Prerequirement

Install package

  • [sudo] npm install -g gulp
  • npm install

Props

showIndicator

Type: boolean Default: true

indicate whether show or hide the scroller bar

direction

Type: enums (v/h/b) Default: 'v'

config the scroll direction. v->short for vertical, h->short for horizontal, b-short for both

lock

Type: boolean Default: false

when you has two scroller in same page and one scroller contains in other scroller, then you scroll, the two scrollers may be both move. Set lock to true can suppress this.

Demos

  • gulp test
  • npm run

then open your browser and type localhost:9527

Example

npm i react-web-scroller -S

import React  from 'react';
import Scroller from 'react-web-scroller';
  
class Page extends React.Component {
  _renderContent() {
    let count, i;
    count = 100;
    let lis = [];
    for(i = 0; i < count; i++ ) {
      lis.push((<li key={`item${i}`} style={styles.item}>item:{i}</li>));
    }
    reuturn (<ul style={styles.list}>{lis}</ul>);
  }
  
  render() {
    let content = this._renderContent();
    return(
      <Scroller style={styles.scroller}
        showIndicator={false} >
        {content}
      </Scroller>
    );
  }
}

let styles = {
  scroller: {
    position: 'absolute',
    top: 0,
    bottom: 0,
    left: 0,
    width: '100%',
    backgroundColor: '#ccc',
  },
  list: {
    marginTop: 0,
    listStyle: 'none',
    paddingLeft: 0,
  },
  item: {
    padding: '0 10px',
    height: '40px',
    lineHeight: '40px',
    borderTop: '1px solid #ccc',
    backgroundColor: '#fafafa',
    fontSize: '14px',
  },
};
  
export default Page;
2.1.0

6 years ago

2.0.0

6 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago