OpenLayers OpenLayers

Changeset 1945

Show
Ignore:
Timestamp:
11/21/06 03:32:13 (2 years ago)
Author:
euzuro
Message:

mousewheel zooms on mouse position. patch from #341. thanks frederic \!

Files:

Legend:

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

    r1721 r1945  
    9595    */ 
    9696    defaultMouseMove: function (evt) { 
     97        // record the mouse position, used in onWheelEvent 
     98        this.mousePosition = evt.xy.clone(); 
     99 
    97100        if (this.mouseDragStart != null) { 
    98101            if (this.zoomBox) { 
     
    156159     *  
    157160     */ 
    158     defaultWheelUp: function()  { 
    159         this.map.zoomIn(); 
     161    defaultWheelUp: function(evt) { 
     162        if (this.map.getZoom() <= this.map.getNumZoomLevels()) { 
     163            this.map.setCenter(this.map.getLonLatFromPixel(evt.xy), 
     164                               this.map.getZoom() + 1); 
     165        } 
    160166    }, 
    161167 
     
    163169     *  
    164170     */ 
    165     defaultWheelDown: function()  { 
    166         this.map.zoomOut(); 
     171    defaultWheelDown: function(evt) { 
     172        if (this.map.getZoom() > 0) { 
     173            this.map.setCenter(this.map.getLonLatFromPixel(evt.xy), 
     174                               this.map.getZoom() - 1); 
     175        } 
    167176    }, 
    168177 
     
    239248            } 
    240249            if (delta) { 
     250                // add the mouse position to the event because mozilla has a bug 
     251                // with clientX and clientY (see https://bugzilla.mozilla.org/show_bug.cgi?id=352179) 
     252                // getLonLatFromViewPortPx(e) returns wrong values 
     253                e.xy = this.mousePosition; 
     254 
    241255                if (delta < 0) { 
    242                    this.defaultWheelDown(); 
     256                   this.defaultWheelDown(e); 
    243257                } else { 
    244                    this.defaultWheelUp(); 
     258                   this.defaultWheelUp(e); 
    245259                } 
    246260            }