Jquery Zepto移动框架-浏览器中的事件

Jquery Zepto移动框架-浏览器中的事件,jquery,mobile,zepto,Jquery,Mobile,Zepto,目前,我正在测试这个Zepto移动Javascript框架 我下载了这些示例,但奇怪的是,我注意到在chrome桌面浏览器上,当单击触发子菜单的项目(通过webkit幻灯片效果)时,该项目不起作用 我在我的托管服务器上上传了相同的文件,并在我的iphone上测试了相同的页面,它工作得非常好 我检查了代码,发现Zepto正在绑定一个touchstart事件,我认为它在桌面浏览器上不起作用 $(document).ready(function(){ $(document.body).bind('to

目前,我正在测试这个Zepto移动Javascript框架

我下载了这些示例,但奇怪的是,我注意到在chrome桌面浏览器上,当单击触发子菜单的项目(通过webkit幻灯片效果)时,该项目不起作用

我在我的托管服务器上上传了相同的文件,并在我的iphone上测试了相同的页面,它工作得非常好

我检查了代码,发现Zepto正在绑定一个touchstart事件,我认为它在桌面浏览器上不起作用

$(document).ready(function(){
$(document.body).bind('touchstart', function(e){
  var now = Date.now(), delta = now - (touch.last || now);
  touch.target = parentIfText(e.touches[0].target);
  touchTimeout && clearTimeout(touchTimeout);
  touch.x1 = e.touches[0].pageX;
  touch.y1 = e.touches[0].pageY;
  if (delta > 0 && delta <= 250) touch.isDoubleTap = true;
  touch.last = now;
}).bind('touchmove', function(e){
  touch.x2 = e.touches[0].pageX;
  touch.y2 = e.touches[0].pageY;
}).bind('touchend', function(e){
  if (touch.isDoubleTap) {
    $(touch.target).trigger('doubleTap');
    touch = {};
  } else if (touch.x2 > 0 || touch.y2 > 0) {
    (Math.abs(touch.x1 - touch.x2) > 30 || Math.abs(touch.y1 - touch.y2) > 30)  &&
      $(touch.target).trigger('swipe') &&
      $(touch.target).trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1,     touch.y2)));
    touch.x1 = touch.x2 = touch.y1 = touch.y2 = touch.last = 0;
  } else if ('last' in touch) {
    touchTimeout = setTimeout(function(){
      touchTimeout = null;
      $(touch.target).trigger('tap')
      touch = {};
    }, 250);
  }
});
  });
$(文档).ready(函数(){
$(document.body).bind('touchstart',函数(e){
var now=Date.now(),delta=now-(touch.last | | now);
touch.target=parentIfText(e.touch[0].target);
touchTimeout&&clearTimeout(touchTimeout);
touch.x1=e.touch[0].pageX;
touch.y1=e.touch[0].pageY;
如果(增量>0&&增量0 | | touch.y2>0){
(Math.abs(touch.x1-touch.x2)>30 | | Math.abs(touch.y1-touch.y2)>30)&&
$(touch.target).trigger('swipe')&&
$(touch.target).trigger('swipe'+(swipeDirection(touch.x1,touch.x2,touch.y1,touch.y2));
touch.x1=touch.x2=touch.y1=touch.y2=touch.last=0;
}否则,如果('最后一次'联系){
touchTimeout=setTimeout(函数(){
touchTimeout=null;
$(touch.target).trigger('tap')
触摸={};
}, 250);
}
});
});
是否有人在Chrome/Safari上测试了Zepto(Iphone示例),并且能够访问子菜单

这是示例URL-

Zepto演示包URL-


谢谢

触摸和点击事件之间存在差异。触摸事件在桌面浏览器中不起作用,但在移动客户端上要快得多,而在桌面浏览器中,点击效果更好。你应该相应地使用它们