[fusion-commits] r1683 - trunk/widgets

svn_fusion at osgeo.org svn_fusion at osgeo.org
Tue Nov 25 13:45:13 EST 2008


Author: madair
Date: 2008-11-25 13:45:13 -0500 (Tue, 25 Nov 2008)
New Revision: 1683

Modified:
   trunk/widgets/Maptip.js
Log:
closes #180: set map size and offset in mousemove event since map.oDomObj may be updating from a zoom and offsets will be null when the tip is being displayed

Modified: trunk/widgets/Maptip.js
===================================================================
--- trunk/widgets/Maptip.js	2008-11-24 20:55:01 UTC (rev 1682)
+++ trunk/widgets/Maptip.js	2008-11-25 18:45:13 UTC (rev 1683)
@@ -93,7 +93,7 @@
         this.iframe.scrolling = 'no';
         this.iframe.frameborder = 0;
         
-         OpenLayers.Event.observe(this.domObj, 'mouseover', OpenLayers.Function.bind(this.mouseOverTip, this));
+        OpenLayers.Event.observe(this.domObj, 'mouseover', OpenLayers.Function.bind(this.mouseOverTip, this));
         OpenLayers.Event.observe(this.domObj, 'mouseout', OpenLayers.Function.bind(this.mouseOutTip, this));
         
         var oDomElem =  this.getMap().getDomObj();
@@ -120,7 +120,12 @@
         if (this.bOverTip) {
             return;
         }
-        var p = this.getMap().getEventPosition(e);
+        
+        var map = this.getMap();
+        this.mapSize = map.getSize();
+        this.mapOffset = map._oDomObj.offsets;
+        
+        var p = map.getEventPosition(e);
         this.oCurrentPosition = p;
         this.oMapTipPosition = p;
         if (this.oCurrentPosition) {
@@ -214,17 +219,14 @@
               empty = false;
             }
             if (!empty) {
-                var map = this.getMap();
-                var mapSize = map.getSize();
                 var size = $(this.domObj).getBorderBoxSize();
-                var offset = map._oDomObj.offsets;
-                this.oMapTipPosition = this.oMapTipPosition.add(offset[0], offset[1]);
-                if (this.oCurrentPosition.x < mapSize.w/2) {
+                this.oMapTipPosition = this.oMapTipPosition.add(this.mapOffset[0], this.mapOffset[1]);
+                if (this.oCurrentPosition.x < this.mapSize.w/2) {
                   this.domObj.style.left = (this.oMapTipPosition.x + this.offset.x) + 'px';
                 } else {
                   this.domObj.style.left = (this.oMapTipPosition.x - (size.width+this.offset.x)) + 'px';
                 }
-                if (this.oCurrentPosition.y < mapSize.h/2) {
+                if (this.oCurrentPosition.y < this.mapSize.h/2) {
                   this.domObj.style.top = (this.oMapTipPosition.y + this.offset.y) + 'px';
                 } else {
                   this.domObj.style.top = (this.oMapTipPosition.y - (size.height+this.offset.y)) + 'px';



More information about the fusion-commits mailing list