* Refactor PanZooMBar so that we don't have three functions that do the exact same thing: These are simply passing information on to the slider, which then actually does the moving, so we'll create passToSlider.

* Alter the dragging code so that you can't drag above or below the top/bottom of the bar.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@397 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-05-26 12:16:02 +00:00
parent 04efcffb00
commit db6049d3b4

View File

@@ -86,9 +86,11 @@ OpenLayers.Control.PanZoomBar.prototype =
imgLocation+"zoombar.png");
}
this.zoombarDiv = div;
this.divEvents = new OpenLayers.Events(this, div);
this.divEvents.register("mousedown", this, this.divClick);
this.divEvents.register("mousemove", this, this.zoomBarDivDrag);
this.divEvents.register("mousemove", this, this.passEventToSlider);
this.divEvents.register("dblclick", this, this.doubleClick);
this.div.appendChild(div);
@@ -109,26 +111,25 @@ OpenLayers.Control.PanZoomBar.prototype =
Event.stop(evt);
},
zoomBarDown:function(evt) {
this.map.events.register("mousemove", this, this.mapMouseDrag);
this.map.events.register("mouseup", this, this.mapMouseUp);
this.map.events.register("mousemove", this, this.passEventToSlider);
this.map.events.register("mouseup", this, this.passEventToSlider);
this.mouseDragStart = evt.xy.copyOf();
this.zoomStart = evt.xy.copyOf();
this.div.style.cursor = "move";
Event.stop(evt);
},
mapMouseDrag:function(evt) {
this.sliderEvents.handleBrowserEvent(evt);
},
mapMouseUp:function(evt) {
this.sliderEvents.handleBrowserEvent(evt);
},
zoomBarDivDrag: function(evt) {
passEventToSlider:function(evt) {
this.sliderEvents.handleBrowserEvent(evt);
},
zoomBarDrag:function(evt) {
if (this.mouseDragStart != null) {
var deltaY = this.mouseDragStart.y - evt.xy.y
this.slider.style.top = (parseInt(this.slider.style.top)-deltaY)+"px";
var offsets = Position.page(this.zoombarDiv);
if ((evt.clientY - offsets[1]) > 0 &&
(evt.clientY - offsets[1]) < parseInt(this.zoombarDiv.style.height) - 2) {
var newTop = parseInt(this.slider.style.top) - deltaY;
this.slider.style.top = newTop+"px";
}
this.mouseDragStart = evt.xy.copyOf();
}
Event.stop(evt);