added option to the MouseWheel handler to trigger up/down events only
when wheel is released. r=elemoine (closes #2345) git-svn-id: http://svn.openlayers.org/trunk/openlayers@9799 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -46,7 +46,14 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
* APIProperty: zoomWheelEnabled
|
||||
* {Boolean} Whether the mousewheel should zoom the map
|
||||
*/
|
||||
zoomWheelEnabled: true,
|
||||
zoomWheelEnabled: true,
|
||||
|
||||
/**
|
||||
* Property: mouseWheelOptions
|
||||
* {Object} Options passed to the MouseWheel control (only useful if
|
||||
* <zoomWheelEnabled> is set to true)
|
||||
*/
|
||||
mouseWheelOptions: null,
|
||||
|
||||
/**
|
||||
* APIProperty: handleRightClicks
|
||||
@@ -159,7 +166,8 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.zoomBox.draw();
|
||||
this.handlers.wheel = new OpenLayers.Handler.MouseWheel(
|
||||
this, {"up" : this.wheelUp,
|
||||
"down": this.wheelDown} );
|
||||
"down": this.wheelDown},
|
||||
this.mouseWheelOptions );
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -192,8 +200,11 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
* deltaZ - {Integer}
|
||||
*/
|
||||
wheelChange: function(evt, deltaZ) {
|
||||
var currentZoom = this.map.getZoom();
|
||||
var newZoom = this.map.getZoom() + deltaZ;
|
||||
if (!this.map.isValidZoomLevel(newZoom)) {
|
||||
newZoom = Math.max(newZoom, 0);
|
||||
newZoom = Math.min(newZoom, this.map.getNumZoomLevels());
|
||||
if (newZoom === currentZoom) {
|
||||
return;
|
||||
}
|
||||
var size = this.map.getSize();
|
||||
@@ -213,9 +224,10 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
* delta - {Integer}
|
||||
*/
|
||||
wheelUp: function(evt) {
|
||||
this.wheelChange(evt, 1);
|
||||
wheelUp: function(evt, delta) {
|
||||
this.wheelChange(evt, delta || 1);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -224,9 +236,10 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
* delta - {Integer}
|
||||
*/
|
||||
wheelDown: function(evt) {
|
||||
this.wheelChange(evt, -1);
|
||||
wheelDown: function(evt, delta) {
|
||||
this.wheelChange(evt, delta || -1);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user