From da1984d764cbd2c0caec7e242e108bc5c89cef08 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Sat, 7 Oct 2006 19:26:31 +0000 Subject: [PATCH] Almost impossible to debug. element.offsets is cached (3x speedup -- a change made in the early days of openlayers) but the cache means that relative mouse positions are off if your first mouse event over the map is *after* the page is scrolled. This closes #333 , and fixes a long standing not-well understood bug. git-svn-id: http://svn.openlayers.org/trunk/openlayers@1692 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Events.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/OpenLayers/Events.js b/lib/OpenLayers/Events.js index ef5bf53950..de38204103 100644 --- a/lib/OpenLayers/Events.js +++ b/lib/OpenLayers/Events.js @@ -319,6 +319,10 @@ OpenLayers.Events.prototype = { getMousePosition: function (evt) { if (!this.element.offsets) { this.element.offsets = OpenLayers.Util.pagePosition(this.element); + this.element.offsets[0] += (document.documentElement.scrollLeft + || document.body.scrollLeft); + this.element.offsets[1] += (document.documentElement.scrollTop + || document.body.scrollTop); } return new OpenLayers.Pixel( (evt.clientX + (document.documentElement.scrollLeft