繁体   English   中英

在phonegap(xcode iOS)中禁用触摸事件

[英]Disable touch events in phonegap (xcode iOS)

我的情况最烦人。 好的,去。 我正在为移动应用程序使用基于javascript的滑动菜单。 “滑块”的工作方式类似于Facebook移动版,您可以单击按钮以显示左侧的菜单,然后再次单击以关闭菜单。 或者,如果在显示菜单时触摸页面的仍可见部分,则该页面也会关闭。 就是这样。

问题:请注意,我正在为此应用程序使用Phonegap。 当我在Xcode中运行iOS模拟器时,例如,向左滑动即可正常运行,但页面会移动。 我想一起禁用滑动事件。 我试过了preventDefault,返回false等。似乎没有任何反应。 同样,我唯一的目标是禁用触摸事件,因为对于此应用程序,我根本不需要它们。 请参阅下面的菜单“显示/隐藏”的JavaScript代码。

感谢是前进。 所有的赞赏。

$(function(){
var menuStatus;     

// Show menu
$("a.showMenu").click(function(){

$('#menu').show();
    if(menuStatus != true){

    $(".ui-page-active").animate({
        marginLeft: "170px",

      }, 300, function(){menuStatus = true});
      return false;
      } else {

        $(".ui-page-active").animate({
            marginLeft: "0px",
      }, 300, function(){menuStatus = false});
        return false;
      }
});

// Menu behaviour
$("#menu li a").click(function(){
    var p = $(this).parent();
    if($(p).hasClass('active')){
        $("#menu li").removeClass('active');
    } else {
        $("#menu li").removeClass('active');
        $(p).addClass('active');
    }
});
}); 

您可以将$.event.special.swipe.horizontalDistanceThreshold为更大的值,并防止页面上的滑动触发滑动事件。

请参阅触摸事件->滑动

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM