【问题标题】:touchstart blocking button listenertouchstart 阻塞按钮监听器
【发布时间】:2012-04-11 14:52:48
【问题描述】:

我正在使用带有 jQ​​uery 触摸事件侦听器的 Seadragon Ajax。

容器绑定了touchstart、touchmove和touchend,这里是touch start:

.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 视图内部是一些生成的按钮。由于其容器 div 上的 touchstart,这些按钮不会在平板电脑上触发。用鼠标就可以了。

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

我需要在 touchstart 功能中的所有内容之前检查触摸是否在按钮上,但真的不确定如何。

【问题讨论】:

    标签: javascript jquery touch seadragon


    【解决方案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);        
    
    
            })
    

    【讨论】:

      猜你喜欢
      • 2014-03-28
      • 1970-01-01
      • 2013-12-24
      • 2021-02-15
      • 1970-01-01
      • 2016-08-27
      • 2013-07-31
      • 2012-02-04
      相关资源
      最近更新 更多