acknowledge that we now do pinch zoom
[lantea.git] / js / map.js
index 77585e27c7eb345cfbc7c346259537f23d50b7bc..dc3ad9c776637595ddbc764b18b111e119dc67ba 100644 (file)
--- a/js/map.js
+++ b/js/map.js
@@ -489,7 +489,6 @@ var mapEvHandler = {
                 Math.pow(aEvent.targetTouches.item(1).clientY -
                          aEvent.targetTouches.item(0).clientY, 2)
             );
-            console.log('!!!' + gPinchStartWidth);
           }
           gDragTouchID = aEvent.changedTouches.item(0).identifier;
           coordObj = aEvent.changedTouches.identifiedTouch(gDragTouchID);
@@ -513,7 +512,9 @@ var mapEvHandler = {
               Math.pow(aEvent.targetTouches.item(1).clientY -
                        aEvent.targetTouches.item(0).clientY, 2)
           );
-          console.log(gPinchStartWidth + ' <?> ' + curPinchStartWidth);
+          if (!gPinchStartWidth)
+            gPinchStartWidth = curPinchStartWidth;
+
           if (gPinchStartWidth / curPinchStartWidth > 1.7 ||
               gPinchStartWidth / curPinchStartWidth < 0.6) {
             var newZoomLevel = gPos.z + (gPinchStartWidth < curPinchStartWidth ? 1 : -1);
@@ -537,8 +538,12 @@ var mapEvHandler = {
                 zoomIn();
               else
                 zoomOut();
+
+              // Reset pinch start width and start another pinch gesture.
+              gPinchStartWidth = null;
             }
           }
+          // If we are in a pinch, do not drag.
           break;
         }
         var x = coordObj.clientX - gMapCanvas.offsetLeft;
@@ -569,6 +574,7 @@ var mapEvHandler = {
         break;
       case "mouseup":
       case "touchend":
+        gPinchStartWidth = null;
         gDragging = false;
         showUI();
         break;