Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update enableCTrace logic

  • Loading branch information...
commit 218fb6a511785d1c3dbcf22174468d6d250a8884 1 parent 028cc03
@shyam-habarakada shyam-habarakada authored
Showing with 25 additions and 4 deletions.
  1. +25 −4 awe-tools.js
View
29 awe-tools.js
@@ -6,9 +6,28 @@
*/
(function(Awe, global, document, undefined) {
- var xyTrace = function(evt) {
- console.log("point:( " + evt.x + ", " + evt.y + " ) of " + evt.currentTarget.id);
+ /*
+ * method: Schedule a timeout that prints out the mouse coordinates only after
+ * mousemove has stopped
+ */
+ var onmousemove = function(evt) {
+ clearTimeout(mousemoveTimer);
+ mousemoveEvent = evt;
+ mousemoveElementId = evt.currentTarget.id;
+ mousemoveTimer = setTimeout(onmousestop, 250);
+ }
+
+ var onmouseout = function(evt) {
+ clearTimeout(mousemoveTimer);
}
+
+ var onmousestop = function() {
+ console.log("point:( " + mousemoveEvent.x + ", " + mousemoveEvent.y + " ) of " + mousemoveElementId);
+ }
+
+ var mousemoveEvent;
+ var mousemoveElementId;
+ var mousemoveTimer;
/*
* method: Awe.enableCTrace
@@ -18,7 +37,8 @@
*/
Awe.enableCTrace = function(elementId) {
var e = document.getElementById(elementId);
- e.addEventListener("mousemove", xyTrace);
+ e.addEventListener("mousemove", onmousemove);
+ e.addEventListener("mouseout", onmouseout);
}
/*
@@ -28,7 +48,8 @@
*/
Awe.disableCTrace = function(elementId) {
var e = document.getElementById(elementId);
- e.removeEventListener("mousemove", xyTrace);
+ e.removeEventListener("mousemove", onmousemove);
+ e.removeEventListener("mouseout", onmouseout);
}
})(Awe, this, document);
Please sign in to comment.
Something went wrong with that request. Please try again.