Skip to content
Browse files

properly hook up touchevents

  • Loading branch information...
1 parent 0d3626a commit f6527a7f52920f765ff044c54f12c376c47a84fe @smindel committed Feb 25, 2012
Showing with 5 additions and 6 deletions.
  1. +5 −6 src/controls.js
View
11 src/controls.js
@@ -25,7 +25,6 @@ Crafty.extend({
mouseDispatch: function (e) {
if (!Crafty.mouseObjs) return;
- if(window.TouchEvent && e instanceof TouchEvent) { this._mockMouseEvent(e); return; }
Crafty.lastEvent = e;
var maxz = -1,
@@ -134,15 +133,15 @@ Crafty.extend({
/**@
- * #Crafty._mockMouseEvent
+ * #Crafty.touchDispatch
* @category Input
* TouchEvents have a different structure then MouseEvents.
* The relevant data lives in e.changedTouches[0].
* To normalize TouchEvents we catch em and dispatch a mock MouseEvent instead.
* @see Crafty.mouseDispatch
*/
- _mockMouseEvent: function(e) {
+ touchDispatch: function(e) {
var type;
if (e.type === "touchstart") type = "mousedown";
@@ -236,9 +235,9 @@ Crafty.bind("Load", function () {
Crafty.addEvent(this, Crafty.stage.elem, "click", Crafty.mouseDispatch);
Crafty.addEvent(this, Crafty.stage.elem, "dblclick", Crafty.mouseDispatch);
- Crafty.addEvent(this, Crafty.stage.elem, "touchstart", Crafty.mouseDispatch);
- Crafty.addEvent(this, Crafty.stage.elem, "touchmove", Crafty.mouseDispatch);
- Crafty.addEvent(this, Crafty.stage.elem, "touchend", Crafty.mouseDispatch);
+ Crafty.addEvent(this, Crafty.stage.elem, "touchstart", Crafty.touchDispatch);
+ Crafty.addEvent(this, Crafty.stage.elem, "touchmove", Crafty.touchDispatch);
+ Crafty.addEvent(this, Crafty.stage.elem, "touchend", Crafty.touchDispatch);
});
/**@

0 comments on commit f6527a7

Please sign in to comment.
Something went wrong with that request. Please try again.