To everyone, I have a problem in my ReactJs app with the onDoubleClick() function assigned to a component, on a desktop pc my function works correctly, but on an Android mobile phone, (iPhone works fine) with the screen in vertical the function doesn't work, the screen in my phone doesn't recognize the double click as my assigned function, instead, it makes zoom in or zoom out, I want to prevent this behavior with my function.
Below is part of my code, and you can see the app in estebmaister.github.io/react-calendar/ or in the public repo with the same name.
onDoubleClick = (event) => {
this.setState({
popperAnchor: Boolean(this.popperAnchor) ? null : event.currentTarget,
});
};
render() {
return (
<td
key={"d" + this.props.day}
className={`calendar-day ${this.props.currentDay}`}
onDoubleClick={this.onDoubleClick}
>
I hope you can give me a clue to fix this problem, thanks.
Here is my solution for double click. Please note that
onDoubleClick
does not work in mobile version of almost all browsers. And you need to useonTapStart
and so on. But I would like to introduce a simple work around that I have tested in Chrome, FireFox and Safari and it works perfect. I made a double click viaonClick
event for aimg
tag.Here, I assumed time difference between 2 clicks is 250 mili seconds, you can increase it even to 300, however, decreasing this value in most browsers does not work.