Commit 08c3f9bc authored by Carlos's avatar Carlos

Resolve #7

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