Adding events to map while dragging in the zoombar, then removing them afterwards. This neccessitated adding a 'remove' to Events, to pop events off the end. No more problems with dragging off into the map accidentally.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@388 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -109,11 +109,19 @@ OpenLayers.Control.PanZoomBar.prototype =
|
|||||||
Event.stop(evt);
|
Event.stop(evt);
|
||||||
},
|
},
|
||||||
zoomBarDown:function(evt) {
|
zoomBarDown:function(evt) {
|
||||||
|
this.map.events.register("mousemove", this, this.mapMouseDrag);
|
||||||
|
this.map.events.register("mouseup", this, this.mapMouseUp);
|
||||||
this.mouseDragStart = evt.xy.copyOf();
|
this.mouseDragStart = evt.xy.copyOf();
|
||||||
this.zoomStart = evt.xy.copyOf();
|
this.zoomStart = evt.xy.copyOf();
|
||||||
this.div.style.cursor = "move";
|
this.div.style.cursor = "move";
|
||||||
Event.stop(evt);
|
Event.stop(evt);
|
||||||
},
|
},
|
||||||
|
mapMouseDrag:function(evt) {
|
||||||
|
this.sliderEvents.handleBrowserEvent(evt);
|
||||||
|
},
|
||||||
|
mapMouseUp:function(evt) {
|
||||||
|
this.sliderEvents.handleBrowserEvent(evt);
|
||||||
|
},
|
||||||
zoomBarDivDrag: function(evt) {
|
zoomBarDivDrag: function(evt) {
|
||||||
this.sliderEvents.handleBrowserEvent(evt);
|
this.sliderEvents.handleBrowserEvent(evt);
|
||||||
},
|
},
|
||||||
@@ -127,6 +135,8 @@ OpenLayers.Control.PanZoomBar.prototype =
|
|||||||
},
|
},
|
||||||
zoomBarUp:function(evt) {
|
zoomBarUp:function(evt) {
|
||||||
this.div.style.cursor="default";
|
this.div.style.cursor="default";
|
||||||
|
this.map.events.remove("mousemove");
|
||||||
|
this.map.events.remove("mouseup");
|
||||||
var deltaY = this.zoomStart.y - evt.xy.y
|
var deltaY = this.zoomStart.y - evt.xy.y
|
||||||
this.map.zoomTo(this.map.zoom + Math.round(deltaY/this.zoomStopHeight));
|
this.map.zoomTo(this.map.zoom + Math.round(deltaY/this.zoomStopHeight));
|
||||||
this.moveZoomBar();
|
this.moveZoomBar();
|
||||||
|
|||||||
@@ -60,6 +60,10 @@ OpenLayers.Events.prototype = {
|
|||||||
listeners.push( func.bindAsEventListener(obj) );
|
listeners.push( func.bindAsEventListener(obj) );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
remove: function(type) {
|
||||||
|
this.listeners[type].pop();
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {event} evt
|
* @param {event} evt
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user