Commit 45c2a7b3 authored by 李勇諭's avatar 李勇諭

fix pull height

parent 4407ccb4
...@@ -89,7 +89,7 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef ...@@ -89,7 +89,7 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
}); });
} }
if (this.currentY - this.startY > this.state.maxPullDownDistance * 1.5) { if (this.currentY - this.startY > this.state.maxPullDownDistance) {
return; return;
} }
...@@ -99,6 +99,10 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef ...@@ -99,6 +99,10 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
@autobind @autobind
private onEnd() { private onEnd() {
this.dragging = false;
this.startY = 0;
this.currentY = 0;
this.setState({ this.setState({
pullToRefreshThresholdBreached: false, pullToRefreshThresholdBreached: false,
onRefreshing: true, onRefreshing: true,
...@@ -110,9 +114,6 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef ...@@ -110,9 +114,6 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
this.container.style.transform = "none"; this.container.style.transform = "none";
this.container.style["willChange"] = "none"; this.container.style["willChange"] = "none";
}); });
this.dragging = false;
this.startY = 0;
this.currentY = 0;
}); });
}); });
} }
......
...@@ -6,7 +6,7 @@ import {PullToRefresh} from "./PullToRefresh"; ...@@ -6,7 +6,7 @@ import {PullToRefresh} from "./PullToRefresh";
const onRefresh = () => { const onRefresh = () => {
return new Promise((reslove) => { return new Promise((reslove) => {
setTimeout(reslove, 3000); setTimeout(reslove, 1000);
}); });
}; };
...@@ -17,13 +17,13 @@ const renderMasterLayout = () => { ...@@ -17,13 +17,13 @@ const renderMasterLayout = () => {
<div> <div>
<div>Header</div> <div>Header</div>
<PullToRefresh <PullToRefresh
pullDownContent={<span>pullDownContent</span>} pullDownContent={<div style={{backgroundColor: "red", height: "200px"}}>pullDownContent</div>}
releaseContent={<span>releaseContent</span>} releaseContent={<div style={{backgroundColor: "red", height: "200px"}}>releaseContent</div>}
refreshContent={<span>refreshing</span>} refreshContent={<div style={{backgroundColor: "red", height: "200px"}}>refreshContent</div>}
pullDownThreshold={50} pullDownThreshold={100}
onRefresh={onRefresh} onRefresh={onRefresh}
> >
<div style={{backgroundColor: "green", height: "300px", color: "white", textAlign: "center"}}> <div style={{backgroundColor: "green", height: "500px", color: "white", textAlign: "center"}}>
PullToRefresh PullToRefresh
</div> </div>
</PullToRefresh> </PullToRefresh>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment