diff --git a/src/component/index.js b/src/component/index.js index b3e20ac..b3d56e3 100644 --- a/src/component/index.js +++ b/src/component/index.js @@ -1,5 +1,4 @@ import React from 'react' -import { clamp } from 'lodash' import { StyleSheet, css } from 'aphrodite' const styles = StyleSheet.create({ @@ -23,25 +22,28 @@ const styles = StyleSheet.create({ } }) -export default (props, state, children) => [ -
- { state.refreshing && 'refreshing :' } - { state.refreshed && 'refreshed :' } - { state.willRefresh && 'willRefresh :' } - { parseInt(state.y, 10) } -
, - children -] +export default (props, state, children) => { + const p = Math.atan(state.y / props.max) + return [ +
+ { state.refreshing && 'refreshing :' } + { state.refreshed && 'refreshed :' } + { state.willRefresh && 'willRefresh :' } + { parseInt(state.y, 10) } +
, + children + ] +} diff --git a/src/index.js b/src/index.js index dda7ba7..b92b05b 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,6 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import Spring from './spring' -import { clamp } from 'lodash' import scrollTop from './scrollTop' import defaultRender from './component' @@ -40,12 +39,11 @@ 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 if(scrollTop(this) <= 0) { - this._y = clamp(this._y + ey - this._py, 0, max + 10) + this._y = this._y + ey - this._py this._spring.endValue = this._y } this._py = ey