Skip to content

Commit

Permalink
Added touch-based input for iOS devices
Browse files Browse the repository at this point in the history
  • Loading branch information
robhawkes committed Sep 8, 2010
1 parent 20e080c commit 11dda87
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions js/main.js
Expand Up @@ -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() {
Expand All @@ -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();
Expand Down

0 comments on commit 11dda87

Please sign in to comment.