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
This commit is contained in:
crschmidt
2006-10-07 19:26:31 +00:00
parent e3386b3d50
commit da1984d764

View File

@@ -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