Commit 08c3f9bc authored by Carlos's avatar Carlos

Resolve #7

parent 64c0146e
/*tslint:disable no-implicit-dependencies*/
import * as React from "react"; import * as React from "react";
import * as renderer from "react-test-renderer"; import * as renderer from "react-test-renderer";
import {PullToRefresh} from "../../src/"; import {PullToRefresh} from "../../src/";
...@@ -14,6 +12,7 @@ describe("PullToRefresh spec", () => { ...@@ -14,6 +12,7 @@ describe("PullToRefresh spec", () => {
releaseContent={<div>Release to refresh</div>} releaseContent={<div>Release to refresh</div>}
refreshContent={<div>Refreshing</div>} refreshContent={<div>Refreshing</div>}
pullDownThreshold={200} pullDownThreshold={200}
triggerHeight={100}
backgroundColor="white" backgroundColor="white"
> >
<div>Test</div> <div>Test</div>
......
...@@ -23,6 +23,7 @@ export class Basic extends React.Component<BasicProps, BasicState> { ...@@ -23,6 +23,7 @@ export class Basic extends React.Component<BasicProps, BasicState> {
refreshContent={<RefreshContent />} refreshContent={<RefreshContent />}
pullDownThreshold={200} pullDownThreshold={200}
onRefresh={this.onRefresh} onRefresh={this.onRefresh}
triggerHeight={100}
backgroundColor="white" backgroundColor="white"
> >
<div id="basic-container"> <div id="basic-container">
......
...@@ -6,6 +6,7 @@ export interface PullToRefreshProps { ...@@ -6,6 +6,7 @@ export interface PullToRefreshProps {
refreshContent: JSX.Element; refreshContent: JSX.Element;
pullDownThreshold: number; pullDownThreshold: number;
onRefresh: () => Promise<any>; onRefresh: () => Promise<any>;
triggerHeight?: number;
backgroundColor?: string; backgroundColor?: string;
} }
...@@ -77,10 +78,12 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef ...@@ -77,10 +78,12 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
} }
private onTouchStart(e) { private onTouchStart(e) {
const {triggerHeight = 40} = this.props;
this.startY = e["pageY"] || e.touches[0].pageY; this.startY = e["pageY"] || e.touches[0].pageY;
this.currentY = this.startY; this.currentY = this.startY;
const top = this.container.getBoundingClientRect().top || this.container.getBoundingClientRect().y || 0; const top = this.container.getBoundingClientRect().top || this.container.getBoundingClientRect().y || 0;
if (this.startY - top > 40) { console.log("this.startY - top", this.startY - top, triggerHeight);
if (this.startY - top > triggerHeight) {
return; return;
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"no-unused-expression": false, "no-unused-expression": false,
"no-duplicate-imports": false, "no-duplicate-imports": false,
"no-trailing-whitespace": false, "no-trailing-whitespace": false,
"no-implicit-dependencies": false,
"jsx-no-multiline-js": false, "jsx-no-multiline-js": false,
"jsx-boolean-value": false, "jsx-boolean-value": false,
"no-object-literal-type-assertion": false, "no-object-literal-type-assertion": false,
......
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