Skip to content
Browse files

Update Mouse so touchmove only fires when the user has the mouse down.

  • Loading branch information...
1 parent faa6e06 commit 947dd85f79732c7940eea593d635a2202fc1c9d9 @cpojer committed Jun 4, 2012
Showing with 10 additions and 4 deletions.
  1. +10 −4 Source/Desktop/Mouse.js
View
14 Source/Desktop/Mouse.js
@@ -18,7 +18,12 @@ provides: Mouse
if (!Browser.Features.Touch) (function(){
-var condition = function(event){
+var down = false;
+var condition = function(event, type){
+ if (type == 'touchstart') down = true;
+ else if (type == 'touchend') down = false;
+ else if (type == 'touchmove' && !down) return false;
+
event.targetTouches = [];
event.changedTouches = event.touches = [{
pageX: event.page.x, pageY: event.page.y,
@@ -31,21 +36,22 @@ var condition = function(event){
Element.defineCustomEvent('touchstart', {
base: 'mousedown',
-
condition: condition
}).defineCustomEvent('touchmove', {
base: 'mousemove',
-
condition: condition
}).defineCustomEvent('touchend', {
base: 'mouseup',
-
condition: condition
});
+document.addEvent('mouseup', function() {
+ down = false;
+});
+
})();

0 comments on commit 947dd85

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