Created
November 15, 2011 12:45
-
-
Save ppcano/1367005 to your computer and use it in GitHub Desktop.
Simulating Touch Events in mouse environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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