Skip to content
This repository has been archived by the owner on Nov 27, 2021. It is now read-only.

Commit

Permalink
bounce on pulled
Browse files Browse the repository at this point in the history
  • Loading branch information
Yusuke Shibata committed Nov 25, 2017
1 parent ec25449 commit 49dc7d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions demo/src/App.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Spring from './spring'
import scrollTop from './scrollTop'
import defaultRender from './component'

export const sleep = msec => new Promise(resolve => setTimeout(resolve, msec))

export default class PullRefresh extends Component {
constructor(props) {
super(props)
Expand All @@ -23,10 +25,12 @@ export default class PullRefresh extends Component {
}
async onUp(evt) {
const { refreshed, refreshing, willRefresh } = this.state
const { onRefresh } = this.props
const { max, onRefresh } = this.props
if(refreshed || refreshing) return
this._down = false
if(willRefresh) {
this._spring.endValue = max
await sleep(400)
this._spring.pause()
this.setState({ willRefresh: false, refreshing: true })
await onRefresh()
Expand Down

0 comments on commit 49dc7d3

Please sign in to comment.