fix reply click handler
This commit is contained in:
@@ -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>
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user