【问题标题】:touchstart too sensitivetouchstart太敏感
【发布时间】:2012-03-11 14:52:51
【问题描述】:

我正在使用这段很棒的代码来模拟 Android http://pervasivecode.blogspot.co.nz/2011/11/android-phonegap-active-css-pseudo.html 上的触摸事件。效果很好,但太敏感了。例如,如果您有一个列表,并且想要在您触摸列表上任何它突出显示的链接时向下滚动。

$(document).ready(function(){
if (navigator.userAgent.toLowerCase().indexOf("android") > -1) {
$('a')
.bind("touchstart", function () {
    $(this).addClass("fake-active");

       })
.bind("touchend", function() {
    $(this).removeClass("fake-active");
  });
 }
    });

是否可以延迟课程更改或者我可以使用其他触发器?

【问题讨论】:

    标签: jquery android web-applications jqtouch


    【解决方案1】:

    为避免在滚动时激活链接,您可以使用 touchend 触发类更改,并检查是否存在滚动。像这样的...

    if (navigator.userAgent.toLowerCase().indexOf("android") > -1){
    
        var scroll = 0;
        $('a').on("touchstart",function(){
            $('a').removeClass("fake-active");
        }).on("touchend",function(){
            if(scroll == 0){
                $(this).addClass("fake-active");
            }
            scroll = 0; //Ideally should be set when scrolling is finished
        });
    
        $('ELEMENT-THAT-IS-SCROLLING').scroll(function(){
        scroll = 1;
        });
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多