From 672d3c4eedfeded74c3ae7da0d0d78034e8b7550 Mon Sep 17 00:00:00 2001 From: euzuro Date: Tue, 5 Feb 2008 06:34:20 +0000 Subject: [PATCH] give the navigation control a proper destroy and also give it a test file while we're at it. (Closes #1289) git-svn-id: http://svn.openlayers.org/trunk/openlayers@5990 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Control/Navigation.js | 25 ++++++++-- tests/Control/test_Navigation.html | 69 ++++++++++++++++++++++++++++ tests/list-tests.html | 1 + 3 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 tests/Control/test_Navigation.html diff --git a/lib/OpenLayers/Control/Navigation.js b/lib/OpenLayers/Control/Navigation.js index e85b48880b..0cd1e67688 100644 --- a/lib/OpenLayers/Control/Navigation.js +++ b/lib/OpenLayers/Control/Navigation.js @@ -62,11 +62,28 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, { */ destroy: function() { OpenLayers.Control.prototype.destroy.apply(this,arguments); + this.deactivate(); - this.dragPan.destroy(); - this.wheelHandler.destroy(); - this.clickHandler.destroy(); - this.zoomBox.destroy(); + + if (this.dragPan) { + this.dragPan.destroy(); + } + this.dragPan = null; + + if (this.wheelHandler) { + this.wheelHandler.destroy(); + } + this.wheelHandler = null; + + if (this.clickHandler) { + this.clickHandler.destroy(); + } + this.clickHandler = null; + + if (this.zoomBox) { + this.zoomBox.destroy(); + } + this.zoomBox = null; }, /** diff --git a/tests/Control/test_Navigation.html b/tests/Control/test_Navigation.html new file mode 100644 index 0000000000..6c390198b5 --- /dev/null +++ b/tests/Control/test_Navigation.html @@ -0,0 +1,69 @@ + + + + + + + + \ No newline at end of file diff --git a/tests/list-tests.html b/tests/list-tests.html index a42ddcf1c6..bd942653f6 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -83,6 +83,7 @@
  • Control/test_ModifyFeature.html
  • Control/test_MousePosition.html
  • Control/test_MouseToolbar.html
  • +
  • Control/test_Navigation.html
  • Control/test_NavToolbar.html
  • Control/test_OverviewMap.html
  • Control/test_Panel.html