Permalink
Browse files

Added touch-based input for iOS devices

  • Loading branch information...
1 parent 20e080c commit 11dda870315eff5bae994b7cb799ee835853f439 @robhawkes committed Sep 8, 2010
Showing with 14 additions and 0 deletions.
  1. +14 −0 js/main.js
View
14 js/main.js
@@ -30,6 +30,15 @@ $(function() {
function initEventListeners() {
$(window).bind('resize', updateCanvasDimensions).bind('mousemove', onMove);
+
+ canvas.get(0).ontouchmove = function(e) {
+ e.preventDefault();
+ onTouchMove(e);
+ };
+
+ canvas.get(0).ontouchstart = function(e) {
+ e.preventDefault();
+ };
};
function updateCanvasDimensions() {
@@ -45,6 +54,11 @@ $(function() {
pointCollection.mousePos.set(e.pageX, e.pageY);
};
+ function onTouchMove(e) {
+ if (pointCollection)
+ pointCollection.mousePos.set(e.targetTouches[0].pageX, e.targetTouches[0].pageY);
+ };
+
function timeout() {
draw();
update();

0 comments on commit 11dda87

Please sign in to comment.