中文
react-pullLoad
Refreshing and Loading more component for react.
pullLoad is another refreshing and loading more lib without react, support require.js to load lib.
examples
demo1 use ReactPullLoad root DOM as container
demo2 use ReactPullLoad root DOM as container
demo3 use document.body as container, and config UI component (HeadNode and FooterNode).
demo4 forbidden pull refresh
version 1.2.0
Support Typescript
Description
- Only depend on react/react-dom, without any other package.
- Use less.
- Support body or root Dom as container.
- Bind touch event on component root Dom.
- It.s develop as Pure react component.
- Support config UI component (HeadNode and FooterNode).
- Can apply refreshing or loading through modify STATE.
- Only support mobile device
How to use
npm install --save react-pullload
;; { super; thisstate = hasMore: true data: cData action: STATSinit index: loadMoreLimitNum //loading more test time limit ; } { console; //new action must do not equel to old action if action === thisstateaction return false; if action === STATSrefreshing this; else if action === STATSloading this; else //DO NOT modify below code this; }; { if STATSrefreshing === thisstateaction return false; ; this; }; { if STATSloading === thisstateaction return false; //无更多内容则不执行后面逻辑 if !thisstatehasMore return; ; this; }; { const data hasMore = thisstate; const fixHeaderStyle = position: "fixed" width: "100%" height: "50px" color: "#fff" lineHeight: "50px" backgroundColor: "#e24f37" left: 0 top: 0 textAlign: "center" zIndex: 1 ; return <div> <div style=fixHeaderStyle>fixed header</div> <ReactPullLoad downEnough=150 action=thisstateaction handleAction=thishandleAction hasMore=hasMore style= paddingTop: 50 distanceBottom=1000 > <ul className="test-ul"> <button onClick=thishandRefreshing>refreshing</button> <button onClick=thishandLoadMore>loading more</button> data </ul> </ReactPullLoad> </div> ; }
API:
Property | Description | Type | default | Remarks |
---|---|---|---|---|
action | sync component status | string | isRequired | |
handleAction | handle status | func | isRequired | |
hasMore | flag for are there any more content to load | bool | false | |
downEnough | how long distance is enough to refreshing | num | 100 | use px as unit |
distanceBottom | current position is apart from bottom | num | 100 | use px as unit |
isBlockContainer | set root dom as container | bool | false | |
HeadNode | custom header UI compoent | any | ReactPullLoad HeadNode | must be a react component |
FooterNode | custom footer UI compoent | any | ReactPullLoad FooterNode | must be a react component |
Remarks: ReactPullLoad support set root dom className and style.
STATS list
Property | Value | root className | explain |
---|---|---|---|
init | '' | component initial status | |
pulling | 'pulling' | state-pulling | pull status |
enough | 'pulling enough' | state-pulling.enough | pull down enough status |
refreshing | 'refreshing' | state-refreshing | refreshing status fetch data |
refreshed | 'refreshed' | state-refreshed | refreshed |
reset | 'reset' | state-reset | reset status |
loading | 'loading' | state-loading | fetching data |
init/reset -> pulling -> enough -> refreshing -> refreshed -> reset
init/reset -> pulling -> reset
init/reset -> loading -> reset
Custom UI components
Please refer to the default HeadNode and FooterNode components
Or refer to demo3, show different dom style through compare props loaderState width STATS.
License
MIT