1

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)

Community
  • 1
  • 1
dopatraman
  • 13,416
  • 29
  • 90
  • 154
  • Does this question still need an answer or has it been solved? If the first, I would have some questions beforehand. – Frank Conijn - Support Ukraine Jun 27 '14 at 13:38
  • Still needs an answer. what are your questions? – dopatraman Jun 27 '14 at 23:02
  • I landed on this thread because of the `browser-detection` tag, and I recently found out how to detect-distinguish between tablets and non-tablets, iOS and Android, and the several browsers on Android. But now that I re-read your question, and especially the non-helpful thread you linked to, it has become clear to me this is not my expertise. Sorry if I gave you false hope! – Frank Conijn - Support Ukraine Jun 28 '14 at 03:14

0 Answers0