From e0b3afadf2a7a2c56b4c4b79532a56adc936b865 Mon Sep 17 00:00:00 2001 From: Robert Konigsberg Date: Fri, 25 Jan 2013 13:40:20 -0500 Subject: [PATCH] resize handler only added once per graph. --- dygraph.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/dygraph.js b/dygraph.js index ecbbca7..3803d9a 100644 --- a/dygraph.js +++ b/dygraph.js @@ -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_); -- 2.7.4