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

Commit

Permalink
cancel with pullup more confortable
Browse files Browse the repository at this point in the history
  • Loading branch information
Yusuke Shibata committed Nov 25, 2017
1 parent 1506f1b commit c4f1b97
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const defaultRender = (props, state, children) => [
justifyContent: 'center'
}}
>
{state.refreshing ? 'refreshing...' : state.refreshed ? 'refreshed' : state.y}
{state.refreshing ? 'refreshing...' : state.refreshed ? 'refreshed' : state.willRefresh ? 'willRefresh' : state.y}
</div>,
children
]
Expand Down Expand Up @@ -58,13 +58,14 @@ export default class PullRefresh extends Component {
}
}
onMove(evt) {
const { max } = this.props
const { refreshed, refreshing } = this.state
if(!this._down || refreshed || refreshing) return
const ey = evt.touches ? evt.touches[0].pageY : evt.pageY
// this._reactInternalInstance._currentElement._owner._instance
// contentOffset.y
if(this._node.scrollTop <= 0) {
this._y += ey - this._py
this._y = clamp(this._y + ey - this._py, 0, max + 10)
this._spring.endValue = this._y
}
this._py = ey
Expand All @@ -76,7 +77,7 @@ export default class PullRefresh extends Component {
this.setState({ y })
if(refreshed && y === 0) this.setState({ refreshed: false })
if(!refreshed && !refreshing) {
const refresh = y > max
const refresh = y >= max
if(refresh !== willRefresh) this.setState({ willRefresh: refresh })
}
}
Expand Down

0 comments on commit c4f1b97

Please sign in to comment.