diff --git a/lib/OpenLayers/Events.js b/lib/OpenLayers/Events.js index de83e342e8..eefa2fbc02 100644 --- a/lib/OpenLayers/Events.js +++ b/lib/OpenLayers/Events.js @@ -72,10 +72,12 @@ OpenLayers.Events.prototype = { * @return {OpenLayers.Pixel} */ getMousePosition: function (evt) { - var offsets = Position.page(this.div); + if (!this.div.offsets) { + this.div.offsets = Position.page(this.div); + } return new OpenLayers.Pixel( - evt.clientX - offsets[0], - evt.clientY - offsets[1]); + evt.clientX - this.div.offsets[0], + evt.clientY - this.div.offsets[1]); }, /** diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 920816d8bc..fafe73eb93 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -207,7 +207,7 @@ OpenLayers.Map.prototype = { updateSize: function() { this.size = new OpenLayers.Size( this.div.clientWidth, this.div.clientHeight); - + this.events.div.offsets = null; // Workaround for the fact that hidden elements return 0 for size. if (this.size.w == 0 && this.size.h == 0) { this.size.w = parseInt(this.div.style.width);