Add new condition to MouseWheelZoom interaction

This commit is contained in:
Frederic Junod
2018-01-08 11:07:46 +01:00
parent 43377c1332
commit 6d83297f24
2 changed files with 20 additions and 0 deletions

View File

@@ -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;