fix reply click handler

This commit is contained in:
xmcp
2019-03-09 14:59:20 +08:00
parent 3da1ea46db
commit b01df1f68f
2 changed files with 44 additions and 6 deletions

View File

@@ -119,4 +119,41 @@ export function PromotionBar(props) {
Safari 将本网站 <b>添加到主屏幕</b>
</div>
) : null;
}
export class ClickHandler extends PureComponent {
constructor(props) {
super(props);
this.state={
moved: false,
};
this.on_begin_bound=this.on_begin.bind(this);
this.on_move_bound=this.on_move.bind(this);
this.on_end_bound=this.on_end.bind(this);
}
on_begin() {
this.setState({
moved: false,
});
}
on_move() {
this.setState({
moved: true,
});
}
on_end(event) {
if(!this.state.moved)
this.props.callback(event);
}
render() {
return (
<div onTouchStart={this.on_begin_bound} onMouseDown={this.on_begin_bound}
onTouchMove={this.on_move_bound} onMouseMove={this.on_move_bound}
onTouchEnd={this.on_end_bound} onMouseUp={this.on_end_bound} >
{this.props.children}
</div>
)
}
}