Expose range selector interaction model publicly (removes need for pull request 101).
authorDan Vanderkam <danvk@google.com>
Mon, 23 Jan 2012 18:16:50 +0000 (13:16 -0500)
committerDan Vanderkam <danvk@google.com>
Mon, 23 Jan 2012 18:16:50 +0000 (13:16 -0500)
dygraph-interaction-model.js
dygraph-range-selector.js

index 55184ec..a3de6f7 100644 (file)
@@ -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);
+    }
+  }
+};
index fe69864..3c76338 100644 (file)
@@ -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';