在phonegap中使用touchstart和touchend事件旁边的滚动

Use scroll beside touchstart and touchend events in phonegap

本文关键字:事件 滚动 touchend phonegap touchstart      更新时间:2023-09-26

我想使用 java 脚本捕获长触摸事件,所以我使用了 touchstart 和 touchend,但应用程序中的滚动已停止。有没有办法长时间触摸并保持滚动功能正常工作

var longpress;
$(document).ready(function(){
  $("#element").on('touchstart' ,function(){ 
  longpress=true;
  setTimeout(function() {
    if(longpress)
      alert("long press works!");
  }, 2000);
})
$("#element").on('touchend' ,function(){ 
   longpress=false;
})

我使用 quo 找到了这个问题的解决方案.js这是修改后的代码

$$('#element').hold(function(event) {
   alert('long tab detected');
}