From 160722a16e6bb7533dea46a2ee6aee8705c22429 Mon Sep 17 00:00:00 2001 From: Schuyler Erle Date: Wed, 28 Mar 2007 22:26:03 +0000 Subject: [PATCH] Reset element.offsets in Map and Control.PanZoomBar every time movement is initiated. Also, reset element.offsets every time map.updateSize() is called. git-svn-id: http://svn.openlayers.org/trunk/openlayers@2915 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Control/PanZoomBar.js | 2 ++ lib/OpenLayers/Map.js | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/OpenLayers/Control/PanZoomBar.js b/lib/OpenLayers/Control/PanZoomBar.js index d67030aa2c..bf153b41c2 100644 --- a/lib/OpenLayers/Control/PanZoomBar.js +++ b/lib/OpenLayers/Control/PanZoomBar.js @@ -167,6 +167,8 @@ OpenLayers.Control.PanZoomBar.prototype = this.mouseDragStart = evt.xy.clone(); this.zoomStart = evt.xy.clone(); this.div.style.cursor = "move"; + // reset the div offsets just in case the div moved + this.zoomBarDiv.offsets = null; OpenLayers.Event.stop(evt); }, diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 2f86218672..816ee5399b 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -179,12 +179,13 @@ OpenLayers.Map.prototype = { this.viewPortDiv.appendChild(this.layerContainerDiv); this.events = new OpenLayers.Events(this, div, this.EVENT_TYPES, this.fallThrough); - this.updateSize(); - // Because Mozilla does not support the "resize" event for elements other - // than "window", we need to put a hack here. - // + // update the map size and location before the map moves + this.events.register("movestart", this, this.updateSize); + + // Because Mozilla does not support the "resize" event for elements other + // than "window", we need to put a hack here. if (navigator.appName.contains("Microsoft")) { // If IE, register the resize on the div this.events.register("resize", this, this.updateSize); @@ -633,6 +634,8 @@ OpenLayers.Map.prototype = { * "onresize" for an element) */ updateSize: function() { + // the div might have moved on the page, also + this.events.element.offsets = null; var newSize = this.getCurrentSize(); var oldSize = this.getSize(); if (oldSize == null) @@ -646,9 +649,6 @@ OpenLayers.Map.prototype = { for(var i=0; i < this.layers.length; i++) { this.layers[i].onMapResize(); } - - // the div might have moved on the page, also - this.events.element.offsets = null; if (this.baseLayer != null) { var center = new OpenLayers.Pixel(newSize.w /2, newSize.h / 2);