Commit 74367f12 authored by 李勇諭's avatar 李勇諭

improve pull ux

parent c79bf47c
...@@ -22,6 +22,12 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef ...@@ -22,6 +22,12 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
this.container = container; this.container = container;
} }
private pullTag: any;
@autobind
private pullTagRef(pullTag) {
this.pullTag = pullTag;
}
private pullDown: any; private pullDown: any;
@autobind @autobind
private pullDownRef(pullDown) { private pullDownRef(pullDown) {
...@@ -45,19 +51,19 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef ...@@ -45,19 +51,19 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
} }
public componentDidMount(): void { public componentDidMount(): void {
this.container.addEventListener("touchstart", this.onTouchStart); this.pullTag.addEventListener("touchstart", this.onTouchStart);
this.container.addEventListener("touchmove", this.onTouchMove); this.container.addEventListener("touchmove", this.onTouchMove);
this.container.addEventListener("touchend", this.onEnd); this.container.addEventListener("touchend", this.onEnd);
this.container.addEventListener("mousedown", this.onTouchStart); this.pullTag.addEventListener("mousedown", this.onTouchStart);
this.container.addEventListener("mousemove", this.onTouchMove); this.container.addEventListener("mousemove", this.onTouchMove);
this.container.addEventListener("mouseup", this.onEnd); this.container.addEventListener("mouseup", this.onEnd);
} }
public componentWillUnmount(): void { public componentWillUnmount(): void {
this.container.removeEventListener("touchstart", this.onTouchStart); this.pullTag.removeEventListener("touchstart", this.onTouchStart);
this.container.removeEventListener("touchmove", this.onTouchMove); this.container.removeEventListener("touchmove", this.onTouchMove);
this.container.removeEventListener("touchend", this.onEnd); this.container.removeEventListener("touchend", this.onEnd);
this.container.removeEventListener("mousedown", this.onTouchStart); this.pullTag.removeEventListener("mousedown", this.onTouchStart);
this.container.removeEventListener("mousemove", this.onTouchMove); this.container.removeEventListener("mousemove", this.onTouchMove);
this.container.removeEventListener("mouseup", this.onEnd); this.container.removeEventListener("mouseup", this.onEnd);
} }
...@@ -160,10 +166,18 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef ...@@ -160,10 +166,18 @@ export class PullToRefresh extends React.Component<PullToRefreshProps, PullToRef
backgroundColor: "white", backgroundColor: "white",
}; };
const pullHiddenTagStyle: React.CSSProperties = {
height: "50px",
width: "100%",
position: "absolute",
top: 0,
};
return ( return (
<div style={containerStyle}> <div style={containerStyle}>
{this.renderPullDownContent()} {this.renderPullDownContent()}
<div ref={this.containerRef} style={containerStyle}> <div ref={this.containerRef} style={containerStyle}>
<div ref={this.pullTagRef} style={pullHiddenTagStyle} />
{this.props.children} {this.props.children}
</div> </div>
</div> </div>
......
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