From: Robert Konigsberg Date: Wed, 15 Dec 2010 23:15:43 +0000 (-0500) Subject: Simplified bindHandler X-Git-Tag: v1.0.0~584^2~21 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=2b188b3d795fd2d60808168a43f7b15466f60b6b;p=dygraphs.git Simplified bindHandler --- diff --git a/dygraph.js b/dygraph.js index f16921e..dd4e7b5 100644 --- a/dygraph.js +++ b/dygraph.js @@ -1090,22 +1090,22 @@ Dygraph.prototype.createDragInterface_ = function() { var interactionModel = this.attr_("interactionModel"); - // Function that binds g and context to the handler. - var bindHandler = function(handler, g) { + // Self is the graph. + var self = this; + + // Function that binds the graph and context to the handler. + var bindHandler = function(handler) { return function(event) { - handler(event, g, context); + handler(event, self, context); }; }; for (var eventName in interactionModel) { if (!interactionModel.hasOwnProperty(eventName)) continue; Dygraph.addEvent(this.mouseEventElement_, eventName, - bindHandler(interactionModel[eventName], this)); + bindHandler(interactionModel[eventName])); } - // Self is the graph. - var self = this; - // If the user releases the mouse button during a drag, but not over the // canvas, then it doesn't count as a zooming action. Dygraph.addEvent(document, 'mouseup', function(event) {