From: Robert Konigsberg Date: Fri, 25 Jan 2013 18:40:20 +0000 (-0500) Subject: resize handler only added once per graph. X-Git-Tag: v1.0.0~111^2~1 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=e0b3afadf2a7a2c56b4c4b79532a56adc936b865;p=dygraphs.git resize handler only added once per graph. --- 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_);