Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将touchmove事件从面板传播到jQueryMobile中的内容_Javascript_Jquery_Jquery Mobile - Fatal编程技术网

Javascript 将touchmove事件从面板传播到jQueryMobile中的内容

Javascript 将touchmove事件从面板传播到jQueryMobile中的内容,javascript,jquery,jquery-mobile,Javascript,Jquery,Jquery Mobile,我在侧面板myPanel上有一个链接myLink和一些内容myContent。我想: 触摸myPanel上的myLink,不要释放触摸 myPanel关闭 touchmove的事件侦听器已添加到myContent,当前触摸尚未结束 myContent在其刚刚开始侦听的touchmove时处理当前触摸 我正在做1到3个这样的动作: $( '#myLink' ).touchstart(function() { $( '#myPanel' ).panel( 'close' ); // addE

我在侧面板myPanel上有一个链接myLink和一些内容myContent。我想:

触摸myPanel上的myLink,不要释放触摸 myPanel关闭 touchmove的事件侦听器已添加到myContent,当前触摸尚未结束 myContent在其刚刚开始侦听的touchmove时处理当前触摸 我正在做1到3个这样的动作:

$( '#myLink' ).touchstart(function() {
  $( '#myPanel' ).panel( 'close' );
  // addEventListener for touchmove somewhere else 
});
我尝试在添加侦听器之前和之后触发touchstart、touchmove和touchend事件,但什么都没有

我在不同的时间对myContent中的touchmove有不同的响应,所以我只想在触动myLink之后添加这个特定的侦听器


我不确定这是不是重复的,我已经找了一段时间了,但我想我对这个术语还不够熟悉。

我猜出来了。我没有在其他地方为touchmove添加侦听器,而是将touchmove绑定到myLink并直接调用外部调用的内容:

$( '#myLink' ).bind('touchstart',function() {
  $( '#myPanel' ).panel( 'close' );
  event.stopPropagation();
  // Don't addEventListener for touchmove
});
$( '#myLink' ).bind('touchmove',function(event) {
  event.stopPropagation();
  // directly call what my previous listener was calling:
  external.onTouchMove(event);
});
诀窍是在处理外部事件时使用originalEvent:

external.prototype.onTouchMove = function(e)
{
  var event = e.originalEvent;
  event.preventDefault();

  // Do what must be done
};

您可以创建一个标志对象f={panel:false,link:true}并在单个移动事件中检查这些标志,而不是添加和删除事件。如果触摸仅使用标志在面板中启动,我是否可以读取内容中触摸移动的坐标?您将正常读取它们。。。只需为touchmove使用一个事件,并在事件函数中使用事件参数进行可能需要的任何测试,我建议使用switch语句。