X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph.js;h=43d30115e0de4efcff8f5044a27e0f06a1e60fb4;hb=946e63b5df4c2fce7af33f24989d4347e0394a1a;hp=3803d9a7d9215805a8bbbaf5d70bb74cf7b724df;hpb=e0b3afadf2a7a2c56b4c4b79532a56adc936b865;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index 3803d9a..43d3011 100644 --- a/dygraph.js +++ b/dygraph.js @@ -956,17 +956,19 @@ Dygraph.prototype.createInterface_ = function() { var dygraph = this; - this.mouseMoveHandler = function(e) { - dygraph.mouseMove_(e); - }; - this.addEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler); + // 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.mouseOutHandler = function(e) { - dygraph.mouseOut_(e); - }; - this.addEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler); + this.mouseOutHandler_ = function(e) { + dygraph.mouseOut_(e); + }; + this.addEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler_); - if (!this.resizeHandler_) { this.resizeHandler_ = function(e) { dygraph.resize(); }; @@ -997,9 +999,14 @@ Dygraph.prototype.destroy = function() { this.registeredEvents_ = []; // remove mouse event handlers (This may not be necessary anymore) - Dygraph.removeEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler); - Dygraph.removeEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler); + Dygraph.removeEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler_); + Dygraph.removeEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler_); Dygraph.removeEvent(this.mouseEventElement_, 'mousemove', this.mouseUpHandler_); + + // remove window handlers + Dygraph.removeEvent(window,'resize',this.resizeHandler_); + this.resizeHandler_ = null; + removeRecursive(this.maindiv_); var nullOut = function(obj) { @@ -1009,9 +1016,6 @@ Dygraph.prototype.destroy = function() { } } }; - // remove event handlers - 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_); @@ -2360,9 +2364,7 @@ Dygraph.prototype.drawGraph_ = function() { if (this.attr_("timingName")) { var end = new Date(); - if (console) { - console.log(this.attr_("timingName") + " - drawGraph: " + (end - start) + "ms"); - } + Dygraph.info(this.attr_("timingName") + " - drawGraph: " + (end - start) + "ms"); } };