Store div offsets in event div object, caching them until a updateSize call. This provides a significant performance gain in places where the div contains hundreds or thousands of markers, because as the div element gets bigger, determining its size through Prototype.element.page() becomes slower by a factor of up to 4 (determined through profiling with venkman).

git-svn-id: http://svn.openlayers.org/trunk/openlayers@271 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-05-22 18:11:45 +00:00
parent 43d9a488df
commit be6ecf5dca
2 changed files with 6 additions and 4 deletions

View File

@@ -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]);
},
/**