[OpenLayers-Commits] r11625 - in sandbox/tschaub/click/lib/OpenLayers: Control Handler

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Sun Mar 6 13:23:13 EST 2011


Author: tschaub
Date: 2011-03-06 10:23:12 -0800 (Sun, 06 Mar 2011)
New Revision: 11625

Modified:
   sandbox/tschaub/click/lib/OpenLayers/Control/PinchZoom.js
   sandbox/tschaub/click/lib/OpenLayers/Handler/Pinch.js
Log:
Better behaved pinching.

Modified: sandbox/tschaub/click/lib/OpenLayers/Control/PinchZoom.js
===================================================================
--- sandbox/tschaub/click/lib/OpenLayers/Control/PinchZoom.js	2011-03-06 17:58:36 UTC (rev 11624)
+++ sandbox/tschaub/click/lib/OpenLayers/Control/PinchZoom.js	2011-03-06 18:23:12 UTC (rev 11625)
@@ -171,21 +171,20 @@
      *     of the pinch gesture. This give us the final scale of the pinch.
      */
     pinchDone: function(evt, start, last) {
+        this.applyTransform("");
         var zoom = this.map.getZoomForResolution(this.map.getResolution() / last.scale, true);
-        var resolution = this.map.getResolutionForZoom(zoom);
+        if (zoom !== this.map.getZoom() || !this.currentCenter.equals(this.pinchOrigin)) {
+            var resolution = this.map.getResolutionForZoom(zoom);
 
-        var location = this.map.getLonLatFromPixel(this.pinchOrigin);
-        var zoomPixel = this.currentCenter;        
-        var size = this.map.getSize();
-        
-        location.lon += resolution * ((size.w / 2) - zoomPixel.x);
-        location.lat -= resolution * ((size.h / 2) - zoomPixel.y);
+            var location = this.map.getLonLatFromPixel(this.pinchOrigin);
+            var zoomPixel = this.currentCenter;        
+            var size = this.map.getSize();
 
-        this.map.setCenter(location, zoom);
+            location.lon += resolution * ((size.w / 2) - zoomPixel.x);
+            location.lat -= resolution * ((size.h / 2) - zoomPixel.y);
 
-        var style = this.map.layerContainerDiv.style;
-        style['-webkit-transform'] = "";
-        style['-moz-transform'] = "";
+            this.map.setCenter(location, zoom);
+        }
     },
 
     CLASS_NAME: "OpenLayers.Control.PinchZoom"

Modified: sandbox/tschaub/click/lib/OpenLayers/Handler/Pinch.js
===================================================================
--- sandbox/tschaub/click/lib/OpenLayers/Handler/Pinch.js	2011-03-06 17:58:36 UTC (rev 11624)
+++ sandbox/tschaub/click/lib/OpenLayers/Handler/Pinch.js	2011-03-06 18:23:12 UTC (rev 11625)
@@ -39,7 +39,7 @@
      * {Boolean} Stop propagation of touchstart events from getting to
      *     listeners on the same element. Default is true.
      */
-    stopDown: true,
+    stopDown: false,
 
     /**
      * Property: pinching
@@ -142,16 +142,14 @@
      * {Boolean} Let the event propagate.
      */
     touchend: function(evt) {
-        var propagate = true;
         if (this.started) {
             this.started = false;
             this.pinching = false;
             this.callback("done", [evt, this.start, this.last]);
             this.start = null;
             this.last = null;
-            propagate = false;
         }
-        return propagate;
+        return true;
     },
 
     /**



More information about the Commits mailing list