OpenLayers OpenLayers

Changeset 397

Show
Ignore:
Timestamp:
05/26/06 08:16:02 (3 years ago)
Author:
crschmidt
Message:
  • 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.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Control/PanZoomBar.js

    r388 r397  
    8787        } 
    8888         
     89        this.zoombarDiv = div; 
     90         
    8991        this.divEvents = new OpenLayers.Events(this, div); 
    9092        this.divEvents.register("mousedown", this, this.divClick); 
    91         this.divEvents.register("mousemove", this, this.zoomBarDivDrag); 
     93        this.divEvents.register("mousemove", this, this.passEventToSlider); 
    9294        this.divEvents.register("dblclick", this, this.doubleClick); 
    9395         
     
    110112    }, 
    111113    zoomBarDown:function(evt) { 
    112         this.map.events.register("mousemove", this, this.mapMouseDrag); 
    113         this.map.events.register("mouseup", this, this.mapMouseUp); 
     114        this.map.events.register("mousemove", this, this.passEventToSlider); 
     115        this.map.events.register("mouseup", this, this.passEventToSlider); 
    114116        this.mouseDragStart = evt.xy.copyOf(); 
    115117        this.zoomStart = evt.xy.copyOf(); 
     
    117119        Event.stop(evt); 
    118120    }, 
    119     mapMouseDrag:function(evt) { 
    120         this.sliderEvents.handleBrowserEvent(evt); 
    121     }, 
    122     mapMouseUp:function(evt) { 
    123         this.sliderEvents.handleBrowserEvent(evt); 
    124     }, 
    125     zoomBarDivDrag: function(evt) { 
     121    passEventToSlider:function(evt) { 
    126122        this.sliderEvents.handleBrowserEvent(evt); 
    127123    }, 
     
    129125        if (this.mouseDragStart != null) { 
    130126            var deltaY = this.mouseDragStart.y - evt.xy.y 
    131             this.slider.style.top = (parseInt(this.slider.style.top)-deltaY)+"px"; 
     127            var offsets = Position.page(this.zoombarDiv); 
     128            if ((evt.clientY - offsets[1]) > 0 &&  
     129                (evt.clientY - offsets[1]) < parseInt(this.zoombarDiv.style.height) - 2) { 
     130                var newTop = parseInt(this.slider.style.top) - deltaY; 
     131                this.slider.style.top = newTop+"px"; 
     132            } 
    132133            this.mouseDragStart = evt.xy.copyOf(); 
    133134        }