MouseDefaults gets a destroy() overhaul.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@2938 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Schuyler Erle
2007-03-30 22:05:58 +00:00
parent 2961be423e
commit 34352e7af7
+37 -7
View File
@@ -18,6 +18,9 @@ OpenLayers.Control.MouseDefaults.prototype =
/** @type Boolean */ /** @type Boolean */
performedDrag: false, performedDrag: false,
/** @type function */
wheelObserver: null,
/** /**
* @constructor * @constructor
*/ */
@@ -25,6 +28,35 @@ OpenLayers.Control.MouseDefaults.prototype =
OpenLayers.Control.prototype.initialize.apply(this, arguments); OpenLayers.Control.prototype.initialize.apply(this, arguments);
}, },
/**
*
*/
destroy: function() {
if (this.handler) {
this.handler.destroy();
}
this.handler = null;
this.map.events.unregister( "click", this, this.defaultClick );
this.map.events.unregister( "dblclick", this, this.defaultDblClick );
this.map.events.unregister( "mousedown", this, this.defaultMouseDown );
this.map.events.unregister( "mouseup", this, this.defaultMouseUp );
this.map.events.unregister( "mousemove", this, this.defaultMouseMove );
this.map.events.unregister( "mouseout", this, this.defaultMouseOut );
//unregister mousewheel events specifically on the window and document
OpenLayers.Event.stopObserving(window, "DOMMouseScroll",
this.wheelObserver);
OpenLayers.Event.stopObserving(window, "mousewheel",
this.wheelObserver);
OpenLayers.Event.stopObserving(document, "mousewheel",
this.wheelObserver);
this.wheelObserver = null;
OpenLayers.Control.prototype.destroy.apply(this, arguments);
},
/** /**
* *
*/ */
@@ -45,14 +77,12 @@ OpenLayers.Control.MouseDefaults.prototype =
*/ */
registerWheelEvents: function() { registerWheelEvents: function() {
//register mousewheel events specifically on the window and document this.wheelObserver = this.onWheelEvent.bindAsEventListener(this);
OpenLayers.Event.observe(window, "DOMMouseScroll",
this.onWheelEvent.bindAsEventListener(this));
OpenLayers.Event.observe(window, "mousewheel",
this.onWheelEvent.bindAsEventListener(this));
OpenLayers.Event.observe(document, "mousewheel",
this.onWheelEvent.bindAsEventListener(this));
//register mousewheel events specifically on the window and document
OpenLayers.Event.observe(window, "DOMMouseScroll", this.wheelObserver);
OpenLayers.Event.observe(window, "mousewheel", this.wheelObserver);
OpenLayers.Event.observe(document, "mousewheel", this.wheelObserver);
}, },
/** /**