Add improved navigation control support for disabling zooming with the

mousewheel. Original from sbenthall (yay), example and more code from me, tests
from elem. r=elemoine.  (Closes #1339)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@6462 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2008-03-07 23:04:32 +00:00
parent 6ee694fc2b
commit d0b4a17116
3 changed files with 96 additions and 2 deletions

View File

@@ -36,6 +36,12 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
*/
zoomBox: null,
/**
* APIProperty: zoomWheelEnabled
* {Boolean} Whether the mousewheel should zoom the map
*/
zoomWheelEnabled: true,
/**
* Constructor: OpenLayers.Control.Navigation
* Create a new navigation control
@@ -75,7 +81,9 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
*/
activate: function() {
this.dragPan.activate();
this.handlers.wheel.activate();
if (this.zoomWheelEnabled) {
this.handlers.wheel.activate();
}
this.handlers.click.activate();
this.zoomBox.activate();
return OpenLayers.Control.prototype.activate.apply(this,arguments);
@@ -168,6 +176,26 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
wheelDown: function(evt) {
this.wheelChange(evt, -1);
},
/**
* Method: disableZoomWheel
*/
disableZoomWheel : function() {
this.zoomWheelEnabled = false;
this.handlers.wheel.deactivate();
},
/**
* Method: enableZoomWheel
*/
enableZoomWheel : function() {
this.zoomWheelEnabled = true;
if (this.active) {
this.handlers.wheel.activate();
}
},
CLASS_NAME: "OpenLayers.Control.Navigation"
});