Does a bodiless function in JavaScript prevent the default of an event?

72 views Asked by At

I set the "passive" Parameter of a touchmove event to true and therefore can't call e.preventDefault() inside the function. But I need the function to prevent the default behaviour of the touchmove event when a certain condition is met, so I replaced the ontouchmove event with this and it works:

disableScroll() {
        document.ontouchmove = () => {
    }
}

The condition mentioned above looks like this

if (dragDistanceX > 3 * dragDistanceY) {
 disableScroll();
}

My question here is: Does this code replace the default behaviour of the event with a function that returns undefined reliably? If not then what do I have to do to prevent the default behaviour without using e.preventDefault or returning false?

0

There are 0 answers