Store a reference to the bound mouse cache clearer so we can unregister it as a listener later. This solves an issue with slider events on the PanZoomBar. r=crschmidt (pullup #2054)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9401 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -435,6 +435,14 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
*/
|
||||
includeXY: false,
|
||||
|
||||
/**
|
||||
* Method: clearMouseListener
|
||||
* A version of <clearMouseCache> that is bound to this instance so that
|
||||
* it can be used with <OpenLayers.Event.observe> and
|
||||
* <OpenLayers.Event.stopObserving>.
|
||||
*/
|
||||
clearMouseListener: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Events
|
||||
* Construct an OpenLayers.Events object.
|
||||
@@ -458,6 +466,11 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
this.eventHandler = OpenLayers.Function.bindAsEventListener(
|
||||
this.handleBrowserEvent, this
|
||||
);
|
||||
|
||||
// to be used with observe and stopObserving
|
||||
this.clearMouseListener = OpenLayers.Function.bind(
|
||||
this.clearMouseCache, this
|
||||
);
|
||||
|
||||
// if eventTypes is specified, create a listeners list for each
|
||||
// custom application event.
|
||||
@@ -481,6 +494,11 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
destroy: function () {
|
||||
if (this.element) {
|
||||
OpenLayers.Event.stopObservingElement(this.element);
|
||||
if(this.element.hasScrollEvent) {
|
||||
OpenLayers.Event.stopObserving(
|
||||
window, "scroll", this.clearMouseListener
|
||||
);
|
||||
}
|
||||
}
|
||||
this.element = null;
|
||||
|
||||
@@ -773,8 +791,7 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
if (!this.includeXY) {
|
||||
this.clearMouseCache();
|
||||
} else if (!this.element.hasScrollEvent) {
|
||||
OpenLayers.Event.observe(window, 'scroll',
|
||||
OpenLayers.Function.bind(this.clearMouseCache, this));
|
||||
OpenLayers.Event.observe(window, "scroll", this.clearMouseListener);
|
||||
this.element.hasScrollEvent = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user