changeset 25:1ca2b2822af1

click throttling
author mgeorgi
date Fri, 22 Jun 2012 18:02:16 +0100
parents 7de24ee1dbe0
children 2ec521bbd543
files nodejs-server/app.js
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/nodejs-server/app.js	Fri Jun 22 17:48:22 2012 +0100
+++ b/nodejs-server/app.js	Fri Jun 22 18:02:16 2012 +0100
@@ -23,6 +23,7 @@
     this.canvas = document.getElementById('canvas');
     this.label = document.getElementById('label');
     this.draw();
+    this.lastClick = new Date();
 
     if (this.is_touch_device) {
       this.canvas.addEventListener('touchstart', function(event) {
@@ -116,9 +117,12 @@
   },
 
   onMouseUp: function(event) {
-    this.setMarker(event);
-    this.sendPosition(event);
-    this.draw();
+    if ((new Date() - this.lastClick) > 1000) {
+      this.setMarker(event);
+      this.sendPosition(event);
+      this.draw();
+      this.lastClick = new Date();
+    }
   },
 
   sendPosition: function(event) {