Search code examples
javascriptmobiletouchdom-events

Is there an add-on or extension to emulate touch events?


In order to develop and debug mobile and tablet applications, I'd like to be able to have my mouse emulate touchstart, touchmove, and touchend.

I have found two possibilities:

Phantom Limb http://www.vodori.com/blog/phantom-limb.html (doesn't seem to work)

ChromeTouch https://chrome.google.com/webstore/detail/ncegfehgjifmmpnjaihnjpbpddjjebme (Scrolls the page, but doesn't fire touch events)

Does anyone know of an addon that will fire touch events in a desktop webkit browser?


Solution

  • The only thing I found to execute touchmove was to do something manually coded like this:

    (function(){
    
    var isDown = false
    ,   dragging
    ;
    
    $('body').bind('mousedown', function(){ isDown = true; });
    $('body').bind('mousemove', function(){ if(isDown) { dragging(); } });    
    $('body').bind('touchmove', function(){ dragging(); });
    $('body').bind('mouseup', function(){ isDown = false; });
    
    dragging = function () {
        console.log('content being drug');
    }
    
    })();