From: Robert Konigsberg <konigsberg@google.com>
Date: Wed, 12 Jan 2011 18:10:05 +0000 (-0800)
Subject: Swapping the smart scroll awareness for a dumber, better, one.
X-Git-Tag: v1.0.0~584^2~9
X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=9d10bca392d2da90786acb16e318c0017063b36a;p=dygraphs.git

Swapping the smart scroll awareness for a dumber, better, one.
---

diff --git a/tests/interaction.html b/tests/interaction.html
index 972b0a3..17911a4 100644
--- a/tests/interaction.html
+++ b/tests/interaction.html
@@ -1,4 +1,3 @@
-
 <html>
   <head>
     <title>interaction model</title>
@@ -46,9 +45,8 @@
     </table>
         
     <script type="text/javascript">
-      Dygraph.addEvent(document, "mousewheel", function() { suspendGraphScroll(); });
-      Dygraph.addEvent(document, "mousedown", function() { clearGraphScroll(); });
-      Dygraph.addEvent(document, "mousemove", function() { clearGraphScroll(); });
+      Dygraph.addEvent(document, "mousewheel", function() { lastClickedGraph = null; });
+      Dygraph.addEvent(document, "click", function() { lastClickedGraph = null; });
       var g = new Dygraph(document.getElementById("div_g"),
            NoisyData, { errorBars : true });
       var g2 = new Dygraph(document.getElementById("div_g2"),
@@ -58,6 +56,7 @@
         'mousedown' : downV3,
         'mousemove' : moveV3,
         'mouseup' : upV3,
+        'click' : clickV3,
         'dblclick' : dblClickV3,
         'mousewheel' : scrollV3
       }});
diff --git a/tests/interaction.js b/tests/interaction.js
index f4925da..279cb8f 100644
--- a/tests/interaction.js
+++ b/tests/interaction.js
@@ -1,6 +1,5 @@
 
 function downV3(event, g, context) {
-  resetGraphScroll();
   context.initializeMouseDown(event, g, context);
   if (event.altKey || event.shiftKey) {
     Dygraph.startZoom(event, g, context);
@@ -10,7 +9,6 @@ function downV3(event, g, context) {
 }
 
 function moveV3(event, g, context) {
-  resetGraphScroll();
   if (context.isPanning) {
     Dygraph.movePan(event, g, context);
   } else if (context.isZooming) {
@@ -73,20 +71,15 @@ function dblClickV3(event, g, context) {
   }
 }
 
-var scrollTimeMillis = 0;
+var lastClickedGraph = null;
 
-function suspendGraphScroll() {
-  scrollTimeMillis = new Date().getTime();
-}
-
-function resetGraphscroll() {
-  scrollTimeMillis = 0;
+function clickV3(event, g, context) {
+  lastClickedGraph = g;
+  Dygraph.cancelEvent(event);
 }
 
 function scrollV3(event, g, context) {
-  var millis = new Date().getTime();
-  if (millis - scrollTimeMillis < 250) {
-    suspendGraphScroll();
+  if (lastClickedGraph != g) {
     return;
   }
   var normal = event.detail ? event.detail * -1 : event.wheelDelta / 40;