这是我的代码段。我正在使用 iscroll 4 在触摸设备和桌面中滚动。
$('#next_item').bind('mousedown touchstart',function (e) {
//do something onclick
$(this).bind('mousemove touchmove',function(e){ //triggers only when i drag over it
dragstart = true;
$(this).css('pointer-events', 'none');
myScroll._start(myDown);
return;
});
});
$('#next_item').bind('mouseup touchend',function (e) {
if(dragstart) {
dragstart = false;
$(this).css('pointer-events', 'auto');
}
});
我有执行特定任务的单击事件#next_item,也有#next_item执行不同任务的拖动事件。现在的问题是当#next_item接收到拖动事件时立即css pointer-events更改为none但拖动没有触发。当我这样做mouseup然后再次从上方拖动时,#next_item只会触发拖动。我需要css pointer-events将拖动事件传递给底层元素。请建议我是否做错了什么。没有pointer-eventsiscroll 在传递下面的拖动事件时会出错#next_item