resize handler only added once per graph.
authorRobert Konigsberg <konigsberg@google.com>
Fri, 25 Jan 2013 18:40:20 +0000 (13:40 -0500)
committerRobert Konigsberg <konigsberg@google.com>
Fri, 25 Jan 2013 18:40:20 +0000 (13:40 -0500)
dygraph.js

index ecbbca7..3803d9a 100644 (file)
@@ -966,13 +966,15 @@ Dygraph.prototype.createInterface_ = function() {
   };
   this.addEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler);
 
-  this.resizeHandler = function(e) {
-    dygraph.resize();
-  };
+  if (!this.resizeHandler_) {
+    this.resizeHandler_ = function(e) {
+      dygraph.resize();
+    };
 
-  // Update when the window is resized.
-  // TODO(danvk): drop frames depending on complexity of the chart.
-  this.addEvent(window, 'resize', this.resizeHandler);
+    // Update when the window is resized.
+    // TODO(danvk): drop frames depending on complexity of the chart.
+    this.addEvent(window, 'resize', this.resizeHandler_);
+  }
 };
 
 /**
@@ -1008,8 +1010,8 @@ Dygraph.prototype.destroy = function() {
     }
   };
   // remove event handlers
-  Dygraph.removeEvent(window,'resize',this.resizeHandler);
-  this.resizeHandler = null;
+  Dygraph.removeEvent(window,'resize',this.resizeHandler_);
+  this.resizeHandler_ = null;
   // These may not all be necessary, but it can't hurt...
   nullOut(this.layout_);
   nullOut(this.plotter_);