[OpenLayers-Commits] r10842 - sandbox/bjornharrtell/swipe/lib/OpenLayers/Control

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Sat Oct 16 13:49:24 EDT 2010


Author: bjornharrtell
Date: 2010-10-16 10:49:24 -0700 (Sat, 16 Oct 2010)
New Revision: 10842

Modified:
   sandbox/bjornharrtell/swipe/lib/OpenLayers/Control/Swipe.js
Log:
Fix behaviour when panning and use IE compatible syntax for clip

Modified: sandbox/bjornharrtell/swipe/lib/OpenLayers/Control/Swipe.js
===================================================================
--- sandbox/bjornharrtell/swipe/lib/OpenLayers/Control/Swipe.js	2010-10-16 13:10:31 UTC (rev 10841)
+++ sandbox/bjornharrtell/swipe/lib/OpenLayers/Control/Swipe.js	2010-10-16 17:49:24 UTC (rev 10842)
@@ -8,11 +8,11 @@
  * Inherits from: - <OpenLayers.Control>
  */
 OpenLayers.Control.Swipe = OpenLayers.Class(OpenLayers.Control, {
-    map: null,
-    layer: null,
-    layerContainerDiv: null,
-    div: null,
-    
+    map : null,
+    layer : null,
+    layerContainerDiv : null,
+    div : null,
+
     /**
      * Property: type {OpenLayers.Control.TYPES}
      */
@@ -21,9 +21,7 @@
     /**
      * Constructor: OpenLayers.Control.Swipe
      * 
-     * Parameters:
-     * layer - {OpenLayers.Layer}
-     * options - {Object} An optional object whose properties will be used to extend the control.
+     * Parameters: layer - {OpenLayers.Layer} options - {Object} An optional object whose properties will be used to extend the control.
      */
     initialize : function(layer, options) {
         this.map = layer.map;
@@ -48,8 +46,8 @@
         var deactivated = OpenLayers.Control.prototype.deactivate.call(this);
 
         if (deactivated) {
-        	this.div.style.clip = '';
-        	
+            this.div.style.clip = '';
+
             this.map.events.un({
                 mousemove : this.onMousemove,
                 scope : this
@@ -58,9 +56,15 @@
     },
 
     onMousemove : function(e) {
-        var offset = (e.clientX - 20) - this.layerContainerDiv.offsetLeft;
+        var offsetX = (e.clientX - this.map.div.offsetLeft) - this.layerContainerDiv.offsetLeft;
+        var offsetY = -this.layerContainerDiv.offsetTop;
 
-        this.div.style.clip = 'rect(0px, '+ this.map.getSize().w +'px, '+ this.map.getSize().h +'px, ' + offset + 'px)';
+        var top = offsetY;
+        var right = this.map.getSize().w + offsetX;
+        var bottom = this.map.getSize().h + offsetY;
+        var left = offsetX;
+
+        this.div.style.clip = 'rect(' + top + 'px ' + right + 'px ' + bottom + 'px ' + left + 'px)';
     },
 
     CLASS_NAME : "OpenLayers.Control.Swipe"



More information about the Commits mailing list