Import events conditions explicitly
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
// FIXME draw drag box
|
||||
import Event from '../events/Event.js';
|
||||
import {inherits, nullFunction} from '../index.js';
|
||||
import _ol_events_condition_ from '../events/condition.js';
|
||||
import {always, mouseOnly, mouseActionButton} from '../events/condition.js';
|
||||
import PointerInteraction from '../interaction/Pointer.js';
|
||||
import _ol_render_Box_ from '../render/Box.js';
|
||||
|
||||
@@ -57,8 +57,7 @@ const DragBox = function(opt_options) {
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
*/
|
||||
this.condition_ = options.condition ?
|
||||
options.condition : _ol_events_condition_.always;
|
||||
this.condition_ = options.condition ? options.condition : always;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -94,7 +93,7 @@ DragBox.defaultBoxEndCondition = function(mapBrowserEvent, startPixel, endPixel)
|
||||
* @private
|
||||
*/
|
||||
DragBox.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) {
|
||||
if (!mouseOnly(mapBrowserEvent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -131,7 +130,7 @@ DragBox.prototype.onBoxEnd = nullFunction;
|
||||
* @private
|
||||
*/
|
||||
DragBox.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) {
|
||||
if (!mouseOnly(mapBrowserEvent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -154,11 +153,11 @@ DragBox.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
* @private
|
||||
*/
|
||||
DragBox.handleDownEvent_ = function(mapBrowserEvent) {
|
||||
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) {
|
||||
if (!mouseOnly(mapBrowserEvent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_ol_events_condition_.mouseActionButton(mapBrowserEvent) &&
|
||||
if (mouseActionButton(mapBrowserEvent) &&
|
||||
this.condition_(mapBrowserEvent)) {
|
||||
this.startPixel_ = mapBrowserEvent.pixel;
|
||||
this.box_.setMap(mapBrowserEvent.map);
|
||||
|
||||
@@ -5,7 +5,7 @@ import {inherits} from '../index.js';
|
||||
import ViewHint from '../ViewHint.js';
|
||||
import _ol_coordinate_ from '../coordinate.js';
|
||||
import {easeOut} from '../easing.js';
|
||||
import _ol_events_condition_ from '../events/condition.js';
|
||||
import {noModifierKeys} from '../events/condition.js';
|
||||
import {FALSE} from '../functions.js';
|
||||
import PointerInteraction from '../interaction/Pointer.js';
|
||||
|
||||
@@ -48,8 +48,7 @@ const DragPan = function(opt_options) {
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
*/
|
||||
this.condition_ = options.condition ?
|
||||
options.condition : _ol_events_condition_.noModifierKeys;
|
||||
this.condition_ = options.condition ? options.condition : noModifierKeys;
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {inherits} from '../index.js';
|
||||
import RotationConstraint from '../RotationConstraint.js';
|
||||
import ViewHint from '../ViewHint.js';
|
||||
import _ol_events_condition_ from '../events/condition.js';
|
||||
import {altShiftKeysOnly, mouseOnly, mouseActionButton} from '../events/condition.js';
|
||||
import {FALSE} from '../functions.js';
|
||||
import Interaction from '../interaction/Interaction.js';
|
||||
import PointerInteraction from '../interaction/Pointer.js';
|
||||
@@ -36,8 +36,7 @@ const DragRotate = function(opt_options) {
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
*/
|
||||
this.condition_ = options.condition ?
|
||||
options.condition : _ol_events_condition_.altShiftKeysOnly;
|
||||
this.condition_ = options.condition ? options.condition : altShiftKeysOnly;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -61,7 +60,7 @@ inherits(DragRotate, PointerInteraction);
|
||||
* @private
|
||||
*/
|
||||
DragRotate.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) {
|
||||
if (!mouseOnly(mapBrowserEvent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -91,7 +90,7 @@ DragRotate.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
* @private
|
||||
*/
|
||||
DragRotate.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) {
|
||||
if (!mouseOnly(mapBrowserEvent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -112,12 +111,11 @@ DragRotate.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
* @private
|
||||
*/
|
||||
DragRotate.handleDownEvent_ = function(mapBrowserEvent) {
|
||||
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) {
|
||||
if (!mouseOnly(mapBrowserEvent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_ol_events_condition_.mouseActionButton(mapBrowserEvent) &&
|
||||
this.condition_(mapBrowserEvent)) {
|
||||
if (mouseActionButton(mapBrowserEvent) && this.condition_(mapBrowserEvent)) {
|
||||
const map = mapBrowserEvent.map;
|
||||
map.getView().setHint(ViewHint.INTERACTING, 1);
|
||||
this.lastAngle_ = undefined;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {inherits} from '../index.js';
|
||||
import RotationConstraint from '../RotationConstraint.js';
|
||||
import ViewHint from '../ViewHint.js';
|
||||
import _ol_events_condition_ from '../events/condition.js';
|
||||
import {shiftKeyOnly, mouseOnly} from '../events/condition.js';
|
||||
import Interaction from '../interaction/Interaction.js';
|
||||
import PointerInteraction from '../interaction/Pointer.js';
|
||||
|
||||
@@ -37,8 +37,7 @@ const DragRotateAndZoom = function(opt_options) {
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
*/
|
||||
this.condition_ = options.condition ?
|
||||
options.condition : _ol_events_condition_.shiftKeyOnly;
|
||||
this.condition_ = options.condition ? options.condition : shiftKeyOnly;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -75,7 +74,7 @@ inherits(DragRotateAndZoom, PointerInteraction);
|
||||
* @private
|
||||
*/
|
||||
DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) {
|
||||
if (!mouseOnly(mapBrowserEvent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -111,7 +110,7 @@ DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
* @private
|
||||
*/
|
||||
DragRotateAndZoom.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) {
|
||||
if (!mouseOnly(mapBrowserEvent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -134,7 +133,7 @@ DragRotateAndZoom.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
* @private
|
||||
*/
|
||||
DragRotateAndZoom.handleDownEvent_ = function(mapBrowserEvent) {
|
||||
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) {
|
||||
if (!mouseOnly(mapBrowserEvent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import {easeOut} from '../easing.js';
|
||||
import _ol_events_condition_ from '../events/condition.js';
|
||||
import {shiftKeyOnly} from '../events/condition.js';
|
||||
import {createOrUpdateFromCoordinates, getBottomLeft, getCenter, getTopRight, scaleFromCenter} from '../extent.js';
|
||||
import DragBox from '../interaction/DragBox.js';
|
||||
|
||||
@@ -24,8 +24,7 @@ import DragBox from '../interaction/DragBox.js';
|
||||
const DragZoom = function(opt_options) {
|
||||
const options = opt_options ? opt_options : {};
|
||||
|
||||
const condition = options.condition ?
|
||||
options.condition : _ol_events_condition_.shiftKeyOnly;
|
||||
const condition = options.condition ? options.condition : shiftKeyOnly;
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -10,7 +10,7 @@ import BaseObject from '../Object.js';
|
||||
import _ol_coordinate_ from '../coordinate.js';
|
||||
import {listen} from '../events.js';
|
||||
import Event from '../events/Event.js';
|
||||
import _ol_events_condition_ from '../events/condition.js';
|
||||
import {noModifierKeys, always, shiftKeyOnly} from '../events/condition.js';
|
||||
import {boundingExtent, getBottomLeft, getBottomRight, getTopLeft, getTopRight} from '../extent.js';
|
||||
import {TRUE, FALSE} from '../functions.js';
|
||||
import Circle from '../geom/Circle.js';
|
||||
@@ -291,8 +291,7 @@ const Draw = function(options) {
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
*/
|
||||
this.condition_ = options.condition ?
|
||||
options.condition : _ol_events_condition_.noModifierKeys;
|
||||
this.condition_ = options.condition ? options.condition : noModifierKeys;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -300,10 +299,10 @@ const Draw = function(options) {
|
||||
*/
|
||||
this.freehandCondition_;
|
||||
if (options.freehand) {
|
||||
this.freehandCondition_ = _ol_events_condition_.always;
|
||||
this.freehandCondition_ = always;
|
||||
} else {
|
||||
this.freehandCondition_ = options.freehandCondition ?
|
||||
options.freehandCondition : _ol_events_condition_.shiftKeyOnly;
|
||||
options.freehandCondition : shiftKeyOnly;
|
||||
}
|
||||
|
||||
listen(this,
|
||||
|
||||
@@ -5,7 +5,7 @@ import {inherits} from '../index.js';
|
||||
import _ol_coordinate_ from '../coordinate.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import KeyCode from '../events/KeyCode.js';
|
||||
import _ol_events_condition_ from '../events/condition.js';
|
||||
import {noModifierKeys, targetNotEditable} from '../events/condition.js';
|
||||
import Interaction from '../interaction/Interaction.js';
|
||||
|
||||
/**
|
||||
@@ -39,8 +39,8 @@ const KeyboardPan = function(opt_options) {
|
||||
* @return {boolean} Combined condition result.
|
||||
*/
|
||||
this.defaultCondition_ = function(mapBrowserEvent) {
|
||||
return _ol_events_condition_.noModifierKeys(mapBrowserEvent) &&
|
||||
_ol_events_condition_.targetNotEditable(mapBrowserEvent);
|
||||
return noModifierKeys(mapBrowserEvent) &&
|
||||
targetNotEditable(mapBrowserEvent);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import _ol_events_condition_ from '../events/condition.js';
|
||||
import {targetNotEditable} from '../events/condition.js';
|
||||
import Interaction from '../interaction/Interaction.js';
|
||||
|
||||
/**
|
||||
@@ -35,8 +35,7 @@ const KeyboardZoom = function(opt_options) {
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
*/
|
||||
this.condition_ = options.condition ? options.condition :
|
||||
_ol_events_condition_.targetNotEditable;
|
||||
this.condition_ = options.condition ? options.condition : targetNotEditable;
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -12,7 +12,7 @@ import _ol_coordinate_ from '../coordinate.js';
|
||||
import {listen, unlisten} from '../events.js';
|
||||
import Event from '../events/Event.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import _ol_events_condition_ from '../events/condition.js';
|
||||
import {always, primaryAction, altKeyOnly, singleClick} from '../events/condition.js';
|
||||
import {boundingExtent, buffer, createOrUpdateFromCoordinate} from '../extent.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
import Point from '../geom/Point.js';
|
||||
@@ -56,8 +56,7 @@ const Modify = function(options) {
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
*/
|
||||
this.condition_ = options.condition ?
|
||||
options.condition : _ol_events_condition_.primaryAction;
|
||||
this.condition_ = options.condition ? options.condition : primaryAction;
|
||||
|
||||
|
||||
/**
|
||||
@@ -66,8 +65,7 @@ const Modify = function(options) {
|
||||
* @return {boolean} Combined condition result.
|
||||
*/
|
||||
this.defaultDeleteCondition_ = function(mapBrowserEvent) {
|
||||
return _ol_events_condition_.altKeyOnly(mapBrowserEvent) &&
|
||||
_ol_events_condition_.singleClick(mapBrowserEvent);
|
||||
return altKeyOnly(mapBrowserEvent) && singleClick(mapBrowserEvent);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -82,7 +80,7 @@ const Modify = function(options) {
|
||||
* @private
|
||||
*/
|
||||
this.insertVertexCondition_ = options.insertVertexCondition ?
|
||||
options.insertVertexCondition : _ol_events_condition_.always;
|
||||
options.insertVertexCondition : always;
|
||||
|
||||
/**
|
||||
* Editing vertex.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import ViewHint from '../ViewHint.js';
|
||||
import condition from '../events/condition.js';
|
||||
import {always} from '../events/condition.js';
|
||||
import {easeOut} from '../easing.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {DEVICE_PIXEL_RATIO, FIREFOX, SAFARI} from '../has.js';
|
||||
@@ -68,7 +68,7 @@ const MouseWheelZoom = function(opt_options) {
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
*/
|
||||
this.condition_ = options.condition ? options.condition : condition.always;
|
||||
this.condition_ = options.condition ? options.condition : always;
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -6,7 +6,7 @@ import CollectionEventType from '../CollectionEventType.js';
|
||||
import {extend, includes} from '../array.js';
|
||||
import {listen} from '../events.js';
|
||||
import Event from '../events/Event.js';
|
||||
import _ol_events_condition_ from '../events/condition.js';
|
||||
import {singleClick, never, shiftKeyOnly, pointerMove} from '../events/condition.js';
|
||||
import {TRUE} from '../functions.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
import Interaction from '../interaction/Interaction.js';
|
||||
@@ -45,29 +45,25 @@ const Select = function(opt_options) {
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
*/
|
||||
this.condition_ = options.condition ?
|
||||
options.condition : _ol_events_condition_.singleClick;
|
||||
this.condition_ = options.condition ? options.condition : singleClick;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
*/
|
||||
this.addCondition_ = options.addCondition ?
|
||||
options.addCondition : _ol_events_condition_.never;
|
||||
this.addCondition_ = options.addCondition ? options.addCondition : never;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
*/
|
||||
this.removeCondition_ = options.removeCondition ?
|
||||
options.removeCondition : _ol_events_condition_.never;
|
||||
this.removeCondition_ = options.removeCondition ? options.removeCondition : never;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.EventsConditionType}
|
||||
*/
|
||||
this.toggleCondition_ = options.toggleCondition ?
|
||||
options.toggleCondition : _ol_events_condition_.shiftKeyOnly;
|
||||
this.toggleCondition_ = options.toggleCondition ? options.toggleCondition : shiftKeyOnly;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -283,7 +279,7 @@ Select.handleEvent = function(mapBrowserEvent) {
|
||||
new Select.Event(Select.EventType_.SELECT,
|
||||
selected, deselected, mapBrowserEvent));
|
||||
}
|
||||
return _ol_events_condition_.pointerMove(mapBrowserEvent);
|
||||
return pointerMove(mapBrowserEvent);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user