Merge pull request #199 from witsa/master
authorDan Vanderkam <danvdk@gmail.com>
Fri, 1 Feb 2013 17:21:51 +0000 (09:21 -0800)
committerDan Vanderkam <danvdk@gmail.com>
Fri, 1 Feb 2013 17:21:51 +0000 (09:21 -0800)
some robustness and partial auto value range

docs/changes.html
dygraph.js

index 6ee7300..12a9d52 100644 (file)
       it.<br/>
       This ensures that we won't inadvertently break your feature in the
       future. To do this, either add to an existing auto_test in
-      auto_tests/tests or run "auto_tests/misc/new-test.sh your-test-name" to
-      create a new one. You can run your auto_test in any browser by visiting
-      auto_tests/misc/local.html.
+      auto_tests/tests or run
+      <code>auto_tests/misc/new-test.sh your-test-name</code> to
+      create a new one. There are two easy ways to run tests:
+      <ul>
+      <li>You can run your auto_test in any browser by visiting
+      <code>auto_tests/misc/local.html</code>. This allows you to debug your
+      test, or test against a specific browser.
+      <li>You can run your auto_test on the command-line by running
+      <code>./test.sh</code>. (It requires installing
+      <a href="http://phantomjs.org">phantomjs</a> on your computer.)
+      </ul>
     </ol>
 
     <h3>Sending a Pull Request</h3>
index 63b2edb..941badb 100644 (file)
@@ -956,19 +956,20 @@ Dygraph.prototype.createInterface_ = function() {
 
   var dygraph = this;
 
-  // Don't recreate and register the handlers on subsequent calls.
-  // This happens when the graph is resized.
-  if (!this.mouseMoveHandler_) {
-    this.mouseMoveHandler_ = function(e) {
-      dygraph.mouseMove_(e);
-    };
-    this.addEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler_);
+  this.mouseMoveHandler_ = function(e) {
+    dygraph.mouseMove_(e);
+  };
 
-    this.mouseOutHandler_ = function(e) {
-      dygraph.mouseOut_(e);
-    };
-    this.addEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler_);
+  this.mouseOutHandler_ = function(e) {
+    dygraph.mouseOut_(e);
+  };
 
+  this.addEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler_);
+  this.addEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler_);
+
+  // Don't recreate and register the resize handler on subsequent calls.
+  // This happens when the graph is resized.
+  if (!this.resizeHandler_) {
     this.resizeHandler_ = function(e) {
       dygraph.resize();
     };
@@ -1280,6 +1281,12 @@ Dygraph.prototype.createDragInterface_ = function() {
         bindHandler(interactionModel[eventName]));
   }
 
+  // unregister the handler on subsequent calls.
+  // This happens when the graph is resized.
+  if (this.mouseUpHandler_) {
+    Dygraph.removeEvent(document, 'mouseup', this.mouseUpHandler_);
+  }
+
   // If the user releases the mouse button during a drag, but not over the
   // canvas, then it doesn't count as a zooming action.
   this.mouseUpHandler_ = function(event) {