Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 832
user1016277 Avatar asked Jun 05 '26 14:06

user1016277


1 Answers

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.

like image 99
Qqwy Avatar answered Jun 07 '26 12:06

Qqwy