From 2b188b3d795fd2d60808168a43f7b15466f60b6b Mon Sep 17 00:00:00 2001 From: Robert Konigsberg Date: Wed, 15 Dec 2010 18:15:43 -0500 Subject: [PATCH] Simplified bindHandler --- dygraph.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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) { -- 2.7.4