Change getMousePosition to only be called automatically *if* the 'includeXY'
flag on the Events object is set to true. This ends up meaning that we save a lot of unneccesary getMousePosition calls because (for example) the layer doesn't need to include the .xy property. In addition, we add in speed improvements via caching to the getMousePosition, courtesy the work from pgiraud (which was worked on further by tcoulter) -- this results in significantly improved getMousePosition performance improvements in 'real life' situations that are more like the cases that people use OpenLayers, with a higher number of containing divs (and also clearly demonstrate a gain in performance even in the simple case.) The end result is: * In typical map movement over the map, (n / n+1) fewer calls to getMousePosition, where n is the number of active layers when dragging over the map. * In the simple case, 40% faster getMousePosition performance -- and in more complex cases, significantly more performance improvements. To drop the former improvement, which may affect some applications (as described in the includeXY documentation) simply set: OpenLayers.Events.prototype.includeXY = true; This will restore the 'every element has an xy property always' behavior that was the case beore this patch. r=me,tschaub, work by pgiraud related to (See #1509), and (Closes #1459) git-svn-id: http://svn.openlayers.org/trunk/openlayers@7615 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -165,7 +165,8 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
"absolute");
|
||||
this.slider = slider;
|
||||
|
||||
this.sliderEvents = new OpenLayers.Events(this, slider, null, true);
|
||||
this.sliderEvents = new OpenLayers.Events(this, slider, null, true,
|
||||
{includeXY: true});
|
||||
this.sliderEvents.on({
|
||||
"mousedown": this.zoomBarDown,
|
||||
"mousemove": this.zoomBarDrag,
|
||||
@@ -197,7 +198,8 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
|
||||
this.zoombarDiv = div;
|
||||
|
||||
this.divEvents = new OpenLayers.Events(this, div, null, true);
|
||||
this.divEvents = new OpenLayers.Events(this, div, null, true,
|
||||
{includeXY: true});
|
||||
this.divEvents.on({
|
||||
"mousedown": this.divClick,
|
||||
"mousemove": this.passEventToSlider,
|
||||
|
||||
Reference in New Issue
Block a user