2012-04-11 87 views
4

我使用Seadragon Ajax和jQuery touch事件监听器。touchstart阻止按钮监听器

该容器具有touchstart,touchmove和绑定到它touchend,继承人的触摸开始:

.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(); 
     }) 

里面海龙视图是生成一些按钮。这些按钮不会在平板电脑上触发,因为它的容器div上有触摸开关。它适用于鼠标。

new Seadragon.Button("Click to go", "", "", "", "", null, moveFunction, null, null, null); 

我需要检查,看看是否触摸是按钮或不是之前在touchstart功能的所有东西,但真的不知道如何。

回答

1

通过添加一个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);   


     })