From 3417f017bd94da8dd934e5a60c2807511005e21c Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Mon, 23 Jan 2012 13:16:50 -0500 Subject: [PATCH] Expose range selector interaction model publicly (removes need for pull request 101). --- dygraph-interaction-model.js | 18 ++++++++++++++++++ dygraph-range-selector.js | 20 ++------------------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/dygraph-interaction-model.js b/dygraph-interaction-model.js index 55184ec..a3de6f7 100644 --- a/dygraph-interaction-model.js +++ b/dygraph-interaction-model.js @@ -418,3 +418,21 @@ Dygraph.Interaction.nonInteractiveModel_ = { } } }; + +// Default interaction model when using the range selector. +Dygraph.Interaction.dragIsPanInteractionModel = { + mousedown: function(event, g, context) { + context.initializeMouseDown(event, g, context); + Dygraph.startPan(event, g, context); + }, + mousemove: function(event, g, context) { + if (context.isPanning) { + Dygraph.movePan(event, g, context); + } + }, + mouseup: function(event, g, context) { + if (context.isPanning) { + Dygraph.endPan(event, g, context); + } + } +}; diff --git a/dygraph-range-selector.js b/dygraph-range-selector.js index fe69864..3c76338 100644 --- a/dygraph-range-selector.js +++ b/dygraph-range-selector.js @@ -342,24 +342,8 @@ DygraphRangeSelector.prototype.initInteraction_ = function() { } }; - var interactionModel = { - mousedown: function(event, g, context) { - context.initializeMouseDown(event, g, context); - Dygraph.startPan(event, g, context); - }, - mousemove: function(event, g, context) { - if (context.isPanning) { - Dygraph.movePan(event, g, context); - } - }, - mouseup: function(event, g, context) { - if (context.isPanning) { - Dygraph.endPan(event, g, context); - } - } - }; - - this.dygraph_.attrs_.interactionModel = interactionModel; + this.dygraph_.attrs_.interactionModel = + Dygraph.Interaction.dragIsPanInteractionModel; this.dygraph_.attrs_.panEdgeFraction = 0.0001; var dragStartEvent = window.opera ? 'mousedown' : 'dragstart'; -- 2.7.4