* 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:
@@ -86,9 +86,11 @@ OpenLayers.Control.PanZoomBar.prototype =
|
|||||||
imgLocation+"zoombar.png");
|
imgLocation+"zoombar.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.zoombarDiv = div;
|
||||||
|
|
||||||
this.divEvents = new OpenLayers.Events(this, div);
|
this.divEvents = new OpenLayers.Events(this, div);
|
||||||
this.divEvents.register("mousedown", this, this.divClick);
|
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.divEvents.register("dblclick", this, this.doubleClick);
|
||||||
|
|
||||||
this.div.appendChild(div);
|
this.div.appendChild(div);
|
||||||
@@ -109,26 +111,25 @@ 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("mousemove", this, this.passEventToSlider);
|
||||||
this.map.events.register("mouseup", this, this.mapMouseUp);
|
this.map.events.register("mouseup", this, this.passEventToSlider);
|
||||||
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) {
|
passEventToSlider:function(evt) {
|
||||||
this.sliderEvents.handleBrowserEvent(evt);
|
|
||||||
},
|
|
||||||
mapMouseUp:function(evt) {
|
|
||||||
this.sliderEvents.handleBrowserEvent(evt);
|
|
||||||
},
|
|
||||||
zoomBarDivDrag: function(evt) {
|
|
||||||
this.sliderEvents.handleBrowserEvent(evt);
|
this.sliderEvents.handleBrowserEvent(evt);
|
||||||
},
|
},
|
||||||
zoomBarDrag:function(evt) {
|
zoomBarDrag:function(evt) {
|
||||||
if (this.mouseDragStart != null) {
|
if (this.mouseDragStart != null) {
|
||||||
var deltaY = this.mouseDragStart.y - evt.xy.y
|
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();
|
this.mouseDragStart = evt.xy.copyOf();
|
||||||
}
|
}
|
||||||
Event.stop(evt);
|
Event.stop(evt);
|
||||||
|
|||||||
Reference in New Issue
Block a user