Skip to content

Instantly share code, notes, and snippets.

@ppcano
Created November 15, 2011 12:45
Show Gist options
  • Save ppcano/1367005 to your computer and use it in GitHub Desktop.
Save ppcano/1367005 to your computer and use it in GitHub Desktop.
Simulating Touch Events in mouse environment
mouseDown: function(evt, view) {
//console.log( ' mouse down.......');
//console.log( evt );
var simulatedEvent = new jQuery.Event();
simulatedEvent.type='touchstart';
simulatedEvent['originalEvent'] = {
targetTouches: [{
id: 0,
pageX: evt.pageX,
pageY: evt.pageY
}]
};
return this.touchStart(simulatedEvent, view);
},
mouseUp: function(evt, view) {
//console.log( ' mouse up.......');
var simulatedEvent = new jQuery.Event();
simulatedEvent.type='touchend';
simulatedEvent['originalEvent'] = {
changedTouches: [{
id: 0,
pageX: evt.pageX,
pageY: evt.pageY
}]
};
return this.touchEnd(simulatedEvent, view);
},
mouseMove: function(evt, view) {
//console.log( ' mouse move.......');
var simulatedEvent = new jQuery.Event();
simulatedEvent.type='touchmove';
simulatedEvent['originalEvent'] = {
changedTouches: [{
id: 0,
pageX: evt.pageX,
pageY: evt.pageY
}]
};
return this.touchMove(simulatedEvent, view);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment