From: Dan Vanderkam Date: Thu, 31 Jan 2013 15:52:38 +0000 (-0800) Subject: Merge pull request #203 from witsa/resize_handler X-Git-Tag: v1.0.0~107 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=e22a354dec471af8011b9fc12751609c6ea39e7f;hp=be6c0f53a9e48ce2277bb1fd8163675c15129c83;p=dygraphs.git Merge pull request #203 from witsa/resize_handler Resize handler --- diff --git a/dygraph.js b/dygraph.js index 43d3011..2580556 100644 --- a/dygraph.js +++ b/dygraph.js @@ -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(); }; @@ -1277,6 +1278,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) {