OpenLayers OpenLayers

Changeset 1215

Show
Ignore:
Timestamp:
08/15/06 08:50:42 (2 years ago)
Author:
euzuro
Message:

scrolling with mousewheel triggers zooming.

Files:

Legend:

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

    r1206 r1215  
    2020    initialize: function() { 
    2121        OpenLayers.Control.prototype.initialize.apply(this, arguments); 
     22 
     23        //register mousewheel events specifically on the window and document 
     24        Event.observe(window, "DOMMouseScroll",  
     25                      this.onWheelEvent.bindAsEventListener(this)); 
     26        Event.observe(window, "mousewheel",  
     27                      this.onWheelEvent.bindAsEventListener(this)); 
     28        Event.observe(document, "mousewheel",  
     29                      this.onWheelEvent.bindAsEventListener(this)); 
    2230    }, 
    2331 
     
    149157        } 
    150158    }, 
     159 
     160 
     161    /** User spun scroll wheel up 
     162     *  
     163     */ 
     164    defaultWheelUp: function()  { 
     165        this.map.zoomIn(); 
     166    }, 
     167 
     168    /** User spun scroll wheel down 
     169     *  
     170     */ 
     171    defaultWheelDown: function()  { 
     172        this.map.zoomOut(); 
     173    }, 
     174 
     175 
     176/** 
     177 *  Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/ 
     178 */ 
     179 
     180 
     181    /** Catch the wheel event and handle it xbrowserly 
     182     *  
     183     * @param {Event} e 
     184     */ 
     185    onWheelEvent: function(e){ 
     186        var delta = 0; 
     187        if (!e) { 
     188            e = window.event; 
     189        } 
     190        if (e.wheelDelta) { 
     191            delta = e.wheelDelta/120;  
     192            if (window.opera) { 
     193                delta = -delta; 
     194            } 
     195        } else if (e.detail) { 
     196            delta = -e.detail / 3; 
     197        } 
     198        if (delta) { 
     199            if (delta < 0) { 
     200               this.map.zoomOut(); 
     201            } else { 
     202               this.map.zoomIn(); 
     203            } 
     204        } 
     205    }, 
     206     
    151207     
    152208    /** @final @type String */