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:
@@ -18,6 +18,9 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
/** @type Boolean */
|
||||
performedDrag: false,
|
||||
|
||||
/** @type function */
|
||||
wheelObserver: null,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
@@ -28,6 +31,35 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
draw: function() {
|
||||
this.map.events.register( "click", this, this.defaultClick );
|
||||
this.map.events.register( "dblclick", this, this.defaultDblClick );
|
||||
@@ -44,15 +76,13 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
*
|
||||
*/
|
||||
registerWheelEvents: function() {
|
||||
|
||||
this.wheelObserver = this.onWheelEvent.bindAsEventListener(this);
|
||||
|
||||
//register mousewheel events specifically on the window and document
|
||||
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));
|
||||
|
||||
OpenLayers.Event.observe(window, "DOMMouseScroll", this.wheelObserver);
|
||||
OpenLayers.Event.observe(window, "mousewheel", this.wheelObserver);
|
||||
OpenLayers.Event.observe(document, "mousewheel", this.wheelObserver);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user