Add mouseWheelZoomDelta option to MapOptions
This commit is contained in:
@@ -9,8 +9,15 @@ goog.require('ol.MapBrowserEvent');
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Interaction}
|
||||
* @param {number} delta The zoom delta applied on each mousewheel.
|
||||
*/
|
||||
ol.interaction.MouseWheelZoom = function() {
|
||||
ol.interaction.MouseWheelZoom = function(delta) {
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.delta_ = delta;
|
||||
|
||||
goog.base(this);
|
||||
};
|
||||
goog.inherits(ol.interaction.MouseWheelZoom, ol.interaction.Interaction);
|
||||
@@ -28,12 +35,8 @@ ol.interaction.MouseWheelZoom.prototype.handleMapBrowserEvent =
|
||||
mapBrowserEvent.browserEvent;
|
||||
goog.asserts.assert(mouseWheelEvent instanceof goog.events.MouseWheelEvent);
|
||||
var anchor = mapBrowserEvent.getCoordinate();
|
||||
var oldResolution = map.getResolution();
|
||||
var factor = Math.exp(Math.log(2) / 4);
|
||||
if (mouseWheelEvent.deltaY < 0) {
|
||||
factor = 1 / factor;
|
||||
}
|
||||
map.zoomToResolution(oldResolution * factor, anchor);
|
||||
var delta = mouseWheelEvent.deltaY < 0 ? this.delta_ : -this.delta_;
|
||||
map.zoom(delta, anchor);
|
||||
mapBrowserEvent.preventDefault();
|
||||
mouseWheelEvent.preventDefault();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user