user1016277
user1016277

Reputation: 83

How do I undo preventDefault(); on touchmove?

if ((body).hasClass('dialog-visible')){
  document.body.addEventListener("touchmove", function(e) {
   e.preventDefault(); 
  }, false);
}

I am trying to remove preventDefault(); when the dialog is closed.

Upvotes: 3

Views: 8047

Answers (1)

Qqwy
Qqwy

Reputation: 5639

There is no 'opposite' of preventDefault(); However, you can choose nót to call it at any given time you want, by moving the if:

  document.body.addEventListener("touchmove", function(e) {
  if((body).hasClass('dialog-visible')){
       e.preventDefault(); 
  }   
  }, false);

Of course, another option is to use document.body.removeEventListener(function, false), but this means you will have to declare your function somewhere.

Upvotes: 2

Related Questions