npm install react-pull2refresh -S
A pull to refresh component for the web.
Based on Andy Peatling's Pull to Refresh for the Web
Your refresh handler function takes in resolve
and reject
to tell the PullToRefresh component when it's finished.
handleRefresh(resolve, reject) {
// do some async code here
if (success) {
resolve();
} else {
reject();
}
}
Where you want to render the component:
<ReactPullToRefresh
onRefresh={this.handleRefresh}
className="your-own-class-if-you-want"
style={{
textAlign: 'center'
}}>
<h3>Pull down to refresh</h3>
<div>{items}</div>
<div>etc.</div>
</ReactPullToRefresh>
Use the CSS from the example or from here as a starting point.
PropTypes
PropTypes.func.isRequired
PropTypes.element
<span className="genericon genericon-next"></span>
PropTypes.element
<div className="loading">
<span className="loading-ptr-1"></span>
<span className="loading-ptr-2"></span>
<span className="loading-ptr-3"></span>
</div>
PropTypes.bool
PropTypes.string
PropTypes.object
PropTypes.number
70
PropTypes.number
2.5
PropTypes.object
to enable proper scroll capablilty, add css as blow
.refresh-view.disabled { transform: translate3d(0px, 0px, 0px) !important; }
.ptr-element.disabled { display: none !important; }
Version | Tag | Published |
---|---|---|
1.1.4 | latest | 4yrs ago |