Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions samples/tracker.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
var i, len = touches.length;
for (i=0; i<len; i++) {
var touch = touches[i];
var px = touch.pageX;
var py = touch.pageY;
var px = touch.pageX;
var py = touch.pageY;

ctx.beginPath();
ctx.arc(px, py, 20, 0, 2*Math.PI, true);
Expand All @@ -53,7 +53,7 @@
ctx.lineWidth = 2.0;
ctx.strokeStyle = "rgba(0, 0, 200, 0.8)";
ctx.stroke();
console.log('drawn circle at ' + px +',' + py);
console.log('drawn circle at ' + px +',' + py);
}

updateStarted = false;
Expand All @@ -64,18 +64,23 @@
ctx = canvas.getContext('2d');
timer = setInterval(update, 15);

canvas.addEventListener('touchend', function() {
ctx.clearRect(0, 0, w, h);
});

canvas.addEventListener('touchmove', function(event) {
event.preventDefault();
touches = event.touches;
});

canvas.addEventListener('touchstart', function(event) {
console.log('start');
});
canvas.addEventListener('touchend', function() {
event.preventDefault();
ctx.clearRect(0, 0, w, h);
touches = [];
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this line to:
touches = event.touches;

});

canvas.addEventListener('touchmove', function(event) {
event.preventDefault();
touches = event.touches;
});

canvas.addEventListener('touchstart', function(event) {
event.preventDefault();
touches = event.touches;
console.log('start');

});
};

</script>
Expand Down