Skip to content

Commit

Permalink
change refresher
Browse files Browse the repository at this point in the history
  • Loading branch information
ali322 committed Apr 1, 2016
1 parent 677d86a commit 1bff619
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/component/refresher.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,15 @@ import React from "react";
import ReactDOM from "react-dom";
import classNames from "classnames";
import dom from "../lib/dom.es6";
import SmoothScroll from "../lib/dom/smoothscroll.es6";

class Refresher extends React.Component{
componentDidMount(){
this.scrollNode = this.props.isInnerScroll?ReactDOM.findDOMNode(this).parentNode:window
// console.log('scrollNode',this.scrollNode)
dom.bindEvent(this.scrollNode,"scroll",(e)=>{
this.handleScroll(this.scrollNode)
})
constructor(props){
super(props)
}
handleScroll(scrollNode){
const {handleRefresh,threshold} = this.props
let scrollTop = dom.scrollTop(scrollNode)
if((scrollNode.offsetHeight + scrollTop + threshold) >= scrollNode.scrollHeight){
handleRefresh()
}
componentDidMount(){
this.scrollNode = ReactDOM.findDOMNode(this).parentNode
dom.bindEvent(this.scrollNode,"scroll",this.handleScroll.bind(this))
}
componentWillUnmount(){
dom.unbindEvent(this.scrollNode,"scroll",(e)=>{
Expand All @@ -38,9 +32,9 @@ class Refresher extends React.Component{
}

Refresher.defaultProps = {
threshold:10,
isInnerScroll:true,
handleRefresh:()=>{}
smooth:false,
active:false,
threshold:10
}

export default Refresher;

0 comments on commit 1bff619

Please sign in to comment.