I'm making a website that will be displayed on a desktop/laptop and a tablet. The problem is that my touch events trigger both mouse and touch events, so the functions that use events like swipe
are called twice. I've tried to solve the problem by detecting the device and then unbinding mouse events. But my approach has not stopped the mouse/touch functions from being triggered twice.
Here is my code:
//Device Detection
(function () {
var agent = navigator.userAgent.toLowerCase();
var isDevice = agent.match(/android/i);
if (isDevice == 'android') {
alert(isDevice);
$('*').unbind('mouseenter mouseleave mousedown mouseup mousemove');
}
})();
This function is placed at the end of my .js
document. I tried to be cautious and unbinded every mouse event I could think of, but it has not worked. Please help.
(Note: this thread's approach has not been helpful either: Click event called twice on touchend in iPad)