Skip to content

Commit

Permalink
fixed touch events
Browse files Browse the repository at this point in the history
  • Loading branch information
ojack committed Jun 15, 2015
1 parent 880b76a commit 5f752dd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
8 changes: 4 additions & 4 deletions compiled.js

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions components/StreetsCanvas.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var React = require('react');
React.initializeTouchEvents(true);

var StreetData = require('../utils/StreetData.js');

var StreetsCanvas = React.createClass({
Expand Down Expand Up @@ -48,13 +48,19 @@ var StreetsCanvas = React.createClass({
}
},
onTouchStart: function(e){
e.preventDefault();
//console.log("touch start");
for(var i = 0; i < e.changedTouches.length; i++){
this.streets.drawNearby(e.changedTouches[i].clientX, e.changedTouches[i].clientY, 5);
this.streets.drawNearby({x: e.changedTouches[i].clientX, y: e.changedTouches[i].clientY}, 6);
}
},
onTouchMove: function(e){
for(var i = 0; i < e.changedTouches.length; i++){
this.streets.drawNearby(e.changedTouches[i].clientX, event.changedTouches[i].clientY, 5);
e.preventDefault();
//console.log("touch move");
//console.log(e.changedTouches);
for(var i = 0; i < e.touches.length; i++){
//console.log("drawing "+ e.touches[i].clientX);
this.streets.drawNearby({x: e.touches[i].clientX, y: event.touches[i].clientY}, 4);
}
},
onTouchEnd: function(e){
Expand Down
1 change: 1 addition & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var React = require('react');
var App = require('./components/App');
React.initializeTouchEvents(true);

React.render(
<App/>,
Expand Down
2 changes: 1 addition & 1 deletion utils/StreetData.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ StreetData.prototype.startDrawing = function(point){

StreetData.prototype.drawNearby = function(point, rad){
var jit = 2;
var speed = 0.15 + d*0.002;
var speed = 0.25;
var nodes = this.nodes;
for (id in nodes) {
if (nodes.hasOwnProperty(id)) {
Expand Down

0 comments on commit 5f752dd

Please sign in to comment.