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:
@@ -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"
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user