I'm trying to get ontouchstart working for windows tablet. If detected it disables the top layer of my links so that a click event allows the menu to remain open (instead of a hover effect).
The following code is working on other touch devices so I'm not sure if there is anything else I need to do?
$topLink.on('click', function (e) {
$dropDown.removeClass('child');
$dropDown.not($(this).next('.dropdown')).removeClass('open');
$topLink.not($(this)).removeClass('active-link');
$(this).next('.dropdown').toggleClass('open');
$(this).toggleClass('active-link');
if (("ontouchstart" in document.documentElement) || ($window.width() < 1120)) {
// disable top level links for touch
e.preventDefault();
e.stopPropagation();
}
});
IE/Edge has no TouchEvents
(at least not enabled by default), it has PointerEvents
.
Have a look at caniuse.com: PointerEvents TouchEvents