0.1.0 • Published 7 years ago

milkui-pullrefresh v0.1.0

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

milkui-pullrefresh

下拉/上拉刷新

Overview

image

Example

import PullRefresh from 'milkui-pullrefresh';

<PullRefresh
  ref={(f) => { this.pullRefresh = f; }}
  topLoad
  onTopLoad={this.events.loadTopData}
  distanceIndex={3}
  bottomLoad
  onBottomLoad={this.events.loadBottomData}
>
  <div className="demo__pullrefresh__list">
    {list.map((item) =>
      <div key={item} className="demo__pullrefresh__item">{item}</div>
    )}
  </div>
</PullRefresh>

// mock loadTopData
loadTopData() {
  const me = this;
  const { list } = me.state;
  let newList = Array.from(list);
  const firstItem = newList[0];
  for (let i = 1; i < 11; i++) {
    newList = [firstItem - i, ...newList];
  }
  setTimeout(() => {
    me.setState({ list: newList }, () => {
      me.pullRefresh.onTopLoaded();
    });
  }, 2000);
}

// mock loadBottomData
loadBottomData() {
  const me = this;
  const { list } = me.state;
  let newList = Array.from(list);
  const lastItem = newList[newList.length - 1];
  for (let i = 1; i < 11; i++) {
    newList = [...newList, lastItem + i];
  }
  setTimeout(() => {
    me.setState({ list: newList }, () => {
      me.pullRefresh.onBottomLoaded();
    });
  }, 2000);
}

Properties

PropertyTypeDescriptionDefault
classNameString自定义的 class 类名''
topPullTextString顶部下拉时的文字提示'↓ 下拉'
topDropTextString顶部下拉后可以刷新时的文字提示'↑ 释放'
topLoadingTextString顶部下拉更新时的文字提示'loading...'
bottomPullTextString底部上拉时的文字提示'↑ 上拉'
bottomDropTextString底部上拉后可以刷新时的文字提示'↓ 释放'
bottomLoadingTextString底部上拉更新时的文字提示'loading...'
distanceIndexNumber手指移动与组件移动距离的比值2
topLoadDistanceNumber顶部下拉更新的阈值70
bottomLoadDistanceNumber底部下拉更新的阈值70
topLoadBoolean顶部下拉更新false
bottomLoadBoolean底部下拉更新false
onTopLoadFunction顶部下拉更新时的回调函数
onBottomLoadFunction底部下拉更新时的回调函数

Develop

cnpm i milk-dev -g    # dev tool

cnpm install

npm start

Links