Skip to content Skip to sidebar Skip to footer

Touch Through An Element In A Browser (like Pointer-events: None)

The problem: I've searched and searched, but I can't find information on how to get a touch event to trigger through an overlay element. I've solved the problem for mouse click ev

Solution 1:

Perhaps this should've been obvious, but I found an answer. Only doing pointer-events: nonedoes work, but only rarely, and I have to move my fingers around quickly to get it to trigger right. In order to make it work 100%, I added a touchstart event listener to the overlay element, like so:

overlay.addEventListener('touchstart', function(e){
  e.preventDefault();
});

This seems a bit silly, but maybe it has to do with how CSS and JavaScript are stepping on each other's toes these days. I don't know.

Interestingly, without e.preventDefault(), it still works, but not 100% of the time. I'm not sure that line is strictly required for this operation to work correctly.

Edit: This is in Android Chrome 31.0.1650.59 by the way.

Post a Comment for "Touch Through An Element In A Browser (like Pointer-events: None)"