Skip to content

Commit

Permalink
only bind touch or mouse events not both
Browse files Browse the repository at this point in the history
  • Loading branch information
thatpixguy committed Sep 10, 2013
1 parent 7751c08 commit 987fb8b
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions lib/quintus_touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ Quintus.Touch = function(Q) {
this.boundDrag = function(e) { touchSystem.drag(e); };
this.boundEnd = function(e) { touchSystem.touchEnd(e); };

Q.el.addEventListener('touchstart',this.boundTouch);
Q.el.addEventListener('mousedown',this.boundTouch);

Q.el.addEventListener('touchmove',this.boundDrag);
Q.el.addEventListener('mousemove',this.boundDrag);

Q.el.addEventListener('touchend',this.boundEnd);
Q.el.addEventListener('mouseup',this.boundEnd);
Q.el.addEventListener('touchcancel',this.boundEnd);
if(hasTouch) {
Q.el.addEventListener('touchstart',this.boundTouch);
Q.el.addEventListener('touchmove',this.boundDrag);
Q.el.addEventListener('touchend',this.boundEnd);
Q.el.addEventListener('touchcancel',this.boundEnd);
} else {
Q.el.addEventListener('mousedown',this.boundTouch);
Q.el.addEventListener('mousemove',this.boundDrag);
Q.el.addEventListener('mouseup',this.boundEnd);
}

this.touchPos = new Q.Evented();
this.touchPos.grid = {};
Expand All @@ -37,15 +38,17 @@ Quintus.Touch = function(Q) {
},

destroy: function() {
Q.el.removeEventListener('touchstart',this.boundTouch);
Q.el.removeEventListener('mousedown',this.boundTouch);

Q.el.removeEventListener('touchmove',this.boundDrag);
Q.el.removeEventListener('mousemove',this.boundDrag);

Q.el.removeEventListener('touchend',this.boundEnd);
Q.el.removeEventListener('mouseup',this.boundEnd);
Q.el.removeEventListener('touchcancel',this.boundEnd);
if(hasTouch) {
Q.el.removeEventListener('touchstart',this.boundTouch);
Q.el.removeEventListener('touchmove',this.boundDrag);
Q.el.removeEventListener('touchend',this.boundEnd);
Q.el.removeEventListener('touchcancel',this.boundEnd);
} else {
Q.el.removeEventListener('mousedown',this.boundTouch);
Q.el.removeEventListener('mousemove',this.boundDrag);
Q.el.removeEventListener('mouseup',this.boundEnd);
}
},

normalizeTouch: function(touch,stage) {
Expand Down

0 comments on commit 987fb8b

Please sign in to comment.