Tareq Salah
Tareq Salah

Reputation: 3718

Use scroll beside touchstart and touchend events in phonegap

I wanted to catch long touch event using java script so I used touchstart and touchend but the scroll in the application is stopped . Is there is a way to catch long touch and keep scroll functionality working

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;
})

Upvotes: 1

Views: 612

Answers (1)

Tareq Salah
Tareq Salah

Reputation: 3718

I found the solution to this problem using quo.js and here's the code after modification

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

Upvotes: 2

Related Questions