better cleanup for ZoomBar and PanZoomBar. Fixes a memory leak.
r=crschmidt (closes #1949) git-svn-id: http://svn.openlayers.org/trunk/openlayers@9113 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -70,20 +70,9 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
*/
|
||||
destroy: function() {
|
||||
|
||||
this.div.removeChild(this.slider);
|
||||
this.slider = null;
|
||||
|
||||
this.sliderEvents.destroy();
|
||||
this.sliderEvents = null;
|
||||
|
||||
this.div.removeChild(this.zoombarDiv);
|
||||
this.zoomBarDiv = null;
|
||||
|
||||
this.divEvents.destroy();
|
||||
this.divEvents = null;
|
||||
this._removeZoomBar();
|
||||
|
||||
this.map.events.un({
|
||||
"zoomend": this.moveZoomBar,
|
||||
"changebaselayer": this.redraw,
|
||||
scope: this
|
||||
});
|
||||
@@ -108,7 +97,8 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
*/
|
||||
redraw: function() {
|
||||
if (this.div != null) {
|
||||
this.div.innerHTML = "";
|
||||
this.removeButtons();
|
||||
this._removeZoomBar();
|
||||
}
|
||||
this.draw();
|
||||
},
|
||||
@@ -223,7 +213,36 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
return centered;
|
||||
},
|
||||
|
||||
/*
|
||||
/**
|
||||
* Method: _removeZoomBar
|
||||
*/
|
||||
_removeZoomBar: function() {
|
||||
this.sliderEvents.un({
|
||||
"mousedown": this.zoomBarDown,
|
||||
"mousemove": this.zoomBarDrag,
|
||||
"mouseup": this.zoomBarUp,
|
||||
"dblclick": this.doubleClick,
|
||||
"click": this.doubleClick
|
||||
});
|
||||
this.sliderEvents.destroy();
|
||||
|
||||
this.divEvents.un({
|
||||
"mousedown": this.divClick,
|
||||
"mousemove": this.passEventToSlider,
|
||||
"dblclick": this.doubleClick,
|
||||
"click": this.doubleClick
|
||||
});
|
||||
this.divEvents.destroy();
|
||||
|
||||
this.div.removeChild(this.zoombarDiv);
|
||||
this.zoombarDiv = null;
|
||||
this.div.removeChild(this.slider);
|
||||
this.slider = null;
|
||||
|
||||
this.map.events.unregister("zoomend", this, this.moveZoomBar);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: passEventToSlider
|
||||
* This function is used to pass events that happen on the div, or the map,
|
||||
* through to the slider, which then does its moving thing.
|
||||
@@ -235,7 +254,7 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
this.sliderEvents.handleBrowserEvent(evt);
|
||||
},
|
||||
|
||||
/*
|
||||
/**
|
||||
* Method: divClick
|
||||
* Picks up on clicks directly on the zoombar div
|
||||
* and sets the zoom level appropriately.
|
||||
|
||||
Reference in New Issue
Block a user