From e946b0a7eba2741d31b7d3b5a452e31aae97016d Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Thu, 21 May 2009 00:20:36 +0000 Subject: [PATCH] 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 --- lib/OpenLayers/Events.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Events.js b/lib/OpenLayers/Events.js index ab806f23f1..bb0d954bf2 100644 --- a/lib/OpenLayers/Events.js +++ b/lib/OpenLayers/Events.js @@ -435,6 +435,14 @@ OpenLayers.Events = OpenLayers.Class({ */ includeXY: false, + /** + * Method: clearMouseListener + * A version of that is bound to this instance so that + * it can be used with and + * . + */ + 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; }