HotStudio / touchy

jQuery plugin for touch events
touchyjs.org/
Other
357 stars 108 forks source link

sending 'touchy-drag' Events to PHP #22

Closed lx2 closed 10 years ago

lx2 commented 10 years ago

Hello,

I want to log all touch-events of an user ( not only events of an specific target div). Especially the 'touchy-drag' - Events should be logged into a file, with something like that:

function sendEventToPhp(e){
    $.post( "dump_events.php", 
    { 
        type        : "END",
        fingerID    : "0",
        x           : "345",
        y           : "678"
    } );
}

var handleTouchyDrag = function (e) {
    sendEventToPhp(e);
};
$('body').bind('touchy-drag', handleTouchyDrag);

/*
document.addEventListener('touchy-drag', function(e) {
    sendEventToPhp(e);
});
*/
  1. Due to the preventDefault, scrolling and zooming isn't working after binding to body and the document.addEventListener doesn't work. How can I modify that.
  2. what would be the right attributes from a touchy-drag event "e" to send. something like that ? : e.type e.id e.x e.y
fisherwebdev commented 10 years ago
  1. There are preventDefault options for each phase: start, move, end. See the source: https://github.com/HotStudio/touchy/blob/master/jquery.touchy.js#L56-L59 Also see the README for info about how to override default setttings: https://github.com/HotStudio/touchy#overriding-default-configuration-settings
  2. For the data, please see the appropriate sections of the README: https://github.com/HotStudio/touchy#data-passed-to-event-handlers https://github.com/HotStudio/touchy#touchy-drag Also see the source: https://github.com/HotStudio/touchy/blob/master/jquery.touchy.js#L145-L149 https://github.com/HotStudio/touchy/blob/master/jquery.touchy.js#L108-L111 etc.