Javascript touchstart阻止按钮侦听器
我将Seadragon Ajax与jQuery touch事件侦听器一起使用 容器已绑定touchstart、touchmove和touchend,以下是touch start:Javascript touchstart阻止按钮侦听器,javascript,jquery,touch,seadragon,Javascript,Jquery,Touch,Seadragon,我将Seadragon Ajax与jQuery touch事件侦听器一起使用 容器已绑定touchstart、touchmove和touchend,以下是touch start: .bind('touchstart MSPointerDown', function(e){ var p = coord(e.originalEvent); p.start = true; p.scale = 1; if(
.bind('touchstart MSPointerDown', function(e){
var p = coord(e.originalEvent);
p.start = true;
p.scale = 1;
if(e.originalEvent.pointerType === 4) return;
else if(e.originalEvent.pointerType !== undefined) e.originalEvent.preventMouseEvent();
$(this).data(p);
e.preventDefault();
e.stopPropagation();
})
在seadragon视图中生成了一些按钮。这些按钮不会在平板电脑上启动,因为它的container div上有touchstart。它可以与鼠标配合使用
new Seadragon.Button("Click to go", "", "", "", "", null, moveFunction, null, null, null );
在touchstart功能中的所有内容之前,我需要检查触摸是否在按钮上,但确实不确定如何操作。通过添加if语句检查触摸次数来解决,如下所示:
.bind('touchstart MSPointerDown', function(e){
if (event.touches.length != 1) {
e.preventDefault();
e.stopPropagation();
}
var p = coord(e.originalEvent);
p.start = true;
p.scale = 1;
if(e.originalEvent.pointerType === 4) return;
else if(e.originalEvent.pointerType !== undefined) e.originalEvent.preventMouseEvent();
$(this).data(p);
})