【发布时间】:2021-10-19 04:56:28
【问题描述】:
嘿,我正在使用带有自定义拖放的 reactjs 创建日历。我在 Ipad 和 Touch 手机上遇到问题。我的代码在桌面上运行完美,但如果我打开 chrome 开发工具并将屏幕分辨率更改为 768px 平板电脑。我的事件也不起作用。请帮助我在父事件和子事件中都使用了cursor:pointer 和e.stopPropagation(),但是没有用。我用 onTouchStart={this.handleTouchStart}
这是我正在使用的代码父事件是
Sectiondoubletap(e) {
debugger
var now = new Date().getTime();
var timesince = now - this.state.mylatesttap;
if((timesince < 300) && (timesince > 0)){
// double tap checking
this._handleDoubleClickSpaltenBody(e)
console.log("Sectiondoubletap worked")
}
this.state.mylatesttap = new Date().getTime();
}
子事件是
handleTouchStart(ev) {
ev.stopPropagation();
console.log("handleTouchStart");
var now = new Date().getTime();
var timesince = now - this.state.mylatesttap;
// checking double tap
if((timesince < 300) && (timesince > 0)){
// double tap checking
this._handleDoubleClickItem(ev)
console.log("Appoinmentdoubletap worked")
}else{
this.handleDrag(ev);
}
this.state.mylatesttap = new Date().getTime();
}
【问题讨论】:
标签: javascript jquery reactjs gesture touch-event