1.0.1 • Published 7 years ago

ygq-rc-listview v1.0.1

Weekly downloads
7
License
MIT
Repository
github
Last release
7 years ago

ygq-rc-listview

NPM version npm download

...v

Demo

https://fdt-component.github.io/rc-listview/docs/index.html

install

ygq-rc-listview

Example

import React from 'react';
import ReactDOM from 'react-dom';
import ListView from 'ygq-rc-listview';

class App extends React.Component {

  state = {
    data: [{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}],
    status: 'more'
  }

  styles = {
    lineHeight: '50px',
    width: '100%',
    background: '#f3f3f3',
    borderBottom: '1px solid #999',
    color: 'orange',
    textAlign: 'center'
  }

  scrollEvent = () => {
    console.log('触发滚动事件');
    const newData = [{},{},{},{},{},{}];
    const {data} = this.state;
    if(data.length > 100) {
      this.setState({
        status: 'done'
      });
    } else {
      setTimeout(() => {
        this.setState({
          data: data.concat(newData)
        });
      }, 100);
    }
  }

  renderItem() {
    return this.state.data.map((item, idx) => (
      <div key={idx} style={this.styles}>item {idx}</div>
    ));
  }

  render() {
    return (
      <ListView
        scrollEvent={this.scrollEvent}
        status={this.state.status}
      >
        <div>{this.renderItem()}</div>
      </ListView>
    );
  }
}

const rootEl = document.createElement('div');
document.body.appendChild(rootEl);
ReactDOM.render(<App />, rootEl);

Props

PropertiesDescritionTypeisRequiredDefault
contentClassname列表的父级类名stringno0
diff预加载距离numberno150(px)
minDelay最小节流numberno20(ms)
moreEle加载中节点nodeno'加载中'
doneEle加载完成节点nodeno'已经到底啦'
noneEle无数据节点nodeno'暂无数据'
scrollEvent滚动触发函数funcno·
status当前列表状态oneOf('more', 'done', 'none')no·

License

The MIT License (MIT)

Copyright (c) 2015 guoquan.yang

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.