Add new condition to MouseWheelZoom interaction
This commit is contained in:
@@ -2772,6 +2772,7 @@ olx.interaction.ModifyOptions.prototype.wrapX;
|
||||
|
||||
/**
|
||||
* @typedef {{constrainResolution: (boolean|undefined),
|
||||
* condition: (ol.EventsConditionType|undefined),
|
||||
* duration: (number|undefined),
|
||||
* timeout: (number|undefined),
|
||||
* useAnchor: (boolean|undefined)}}
|
||||
@@ -2779,6 +2780,15 @@ olx.interaction.ModifyOptions.prototype.wrapX;
|
||||
olx.interaction.MouseWheelZoomOptions;
|
||||
|
||||
|
||||
/**
|
||||
* A function that takes an {@link ol.MapBrowserEvent} and returns a boolean
|
||||
* to indicate whether that event should be handled. Default is {@link ol.events.condition.always}.
|
||||
* @type {ol.EventsConditionType|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.MouseWheelZoomOptions.prototype.condition;
|
||||
|
||||
|
||||
/**
|
||||
* Animation duration in milliseconds. Default is `250`.
|
||||
* @type {number|undefined}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_ViewHint_ from '../ViewHint.js';
|
||||
import condition from '../events/condition.js';
|
||||
import {easeOut} from '../easing.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import _ol_has_ from '../has.js';
|
||||
@@ -63,6 +64,12 @@ var MouseWheelZoom = function(opt_options) {
|
||||
*/
|
||||
this.constrainResolution_ = options.constrainResolution || false;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
*/
|
||||
this.condition_ = options.condition ? options.condition : condition.always;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {?ol.Coordinate}
|
||||
@@ -127,6 +134,9 @@ inherits(MouseWheelZoom, Interaction);
|
||||
* @api
|
||||
*/
|
||||
MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
|
||||
if (!this.condition_(mapBrowserEvent)) {
|
||||
return true;
|
||||
}
|
||||
var type = mapBrowserEvent.type;
|
||||
if (type !== EventType.WHEEL && type !== EventType.MOUSEWHEEL) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user