Merge pull request #7765 from marcjansen/names-names-names

Named exports from events condition
This commit is contained in:
Marc Jansen
2018-02-05 22:16:34 +01:00
committed by GitHub
17 changed files with 69 additions and 86 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
import Map from '../src/ol/Map.js'; import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js'; import View from '../src/ol/View.js';
import _ol_events_condition_ from '../src/ol/events/condition.js'; import {platformModifierKeyOnly} from '../src/ol/events/condition.js';
import GeoJSON from '../src/ol/format/GeoJSON.js'; import GeoJSON from '../src/ol/format/GeoJSON.js';
import DragBox from '../src/ol/interaction/DragBox.js'; import DragBox from '../src/ol/interaction/DragBox.js';
import Select from '../src/ol/interaction/Select.js'; import Select from '../src/ol/interaction/Select.js';
@@ -40,7 +40,7 @@ const selectedFeatures = select.getFeatures();
// a DragBox interaction used to select features by drawing boxes // a DragBox interaction used to select features by drawing boxes
const dragBox = new DragBox({ const dragBox = new DragBox({
condition: _ol_events_condition_.platformModifierKeyOnly condition: platformModifierKeyOnly
}); });
map.addInteraction(dragBox); map.addInteraction(dragBox);
+2 -2
View File
@@ -1,6 +1,6 @@
import Map from '../src/ol/Map.js'; import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js'; import View from '../src/ol/View.js';
import _ol_events_condition_ from '../src/ol/events/condition.js'; import {platformModifierKeyOnly} from '../src/ol/events/condition.js';
import GeoJSON from '../src/ol/format/GeoJSON.js'; import GeoJSON from '../src/ol/format/GeoJSON.js';
import ExtentInteraction from '../src/ol/interaction/Extent.js'; import ExtentInteraction from '../src/ol/interaction/Extent.js';
import TileLayer from '../src/ol/layer/Tile.js'; import TileLayer from '../src/ol/layer/Tile.js';
@@ -30,7 +30,7 @@ const map = new Map({
}); });
const extent = new ExtentInteraction({ const extent = new ExtentInteraction({
condition: _ol_events_condition_.platformModifierKeyOnly condition: platformModifierKeyOnly
}); });
map.addInteraction(extent); map.addInteraction(extent);
extent.setActive(false); extent.setActive(false);
+4 -5
View File
@@ -1,6 +1,6 @@
import Map from '../src/ol/Map.js'; import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js'; import View from '../src/ol/View.js';
import _ol_events_condition_ from '../src/ol/events/condition.js'; import {click, pointerMove, altKeyOnly} from '../src/ol/events/condition.js';
import GeoJSON from '../src/ol/format/GeoJSON.js'; import GeoJSON from '../src/ol/format/GeoJSON.js';
import Select from '../src/ol/interaction/Select.js'; import Select from '../src/ol/interaction/Select.js';
import TileLayer from '../src/ol/layer/Tile.js'; import TileLayer from '../src/ol/layer/Tile.js';
@@ -35,18 +35,17 @@ const selectSingleClick = new Select();
// select interaction working on "click" // select interaction working on "click"
const selectClick = new Select({ const selectClick = new Select({
condition: _ol_events_condition_.click condition: click
}); });
// select interaction working on "pointermove" // select interaction working on "pointermove"
const selectPointerMove = new Select({ const selectPointerMove = new Select({
condition: _ol_events_condition_.pointerMove condition: pointerMove
}); });
const selectAltClick = new Select({ const selectAltClick = new Select({
condition: function(mapBrowserEvent) { condition: function(mapBrowserEvent) {
return _ol_events_condition_.click(mapBrowserEvent) && return click(mapBrowserEvent) && altKeyOnly(mapBrowserEvent);
_ol_events_condition_.altKeyOnly(mapBrowserEvent);
} }
}); });
+15 -17
View File
@@ -5,7 +5,6 @@ import MapBrowserEventType from '../MapBrowserEventType.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
import {TRUE, FALSE} from '../functions.js'; import {TRUE, FALSE} from '../functions.js';
import {WEBKIT, MAC} from '../has.js'; import {WEBKIT, MAC} from '../has.js';
const _ol_events_condition_ = {};
/** /**
@@ -16,7 +15,7 @@ const _ol_events_condition_ = {};
* @return {boolean} True if only the alt key is pressed. * @return {boolean} True if only the alt key is pressed.
* @api * @api
*/ */
_ol_events_condition_.altKeyOnly = function(mapBrowserEvent) { export const altKeyOnly = function(mapBrowserEvent) {
const originalEvent = mapBrowserEvent.originalEvent; const originalEvent = mapBrowserEvent.originalEvent;
return ( return (
originalEvent.altKey && originalEvent.altKey &&
@@ -33,7 +32,7 @@ _ol_events_condition_.altKeyOnly = function(mapBrowserEvent) {
* @return {boolean} True if only the alt and shift keys are pressed. * @return {boolean} True if only the alt and shift keys are pressed.
* @api * @api
*/ */
_ol_events_condition_.altShiftKeysOnly = function(mapBrowserEvent) { export const altShiftKeysOnly = function(mapBrowserEvent) {
const originalEvent = mapBrowserEvent.originalEvent; const originalEvent = mapBrowserEvent.originalEvent;
return ( return (
originalEvent.altKey && originalEvent.altKey &&
@@ -50,7 +49,7 @@ _ol_events_condition_.altShiftKeysOnly = function(mapBrowserEvent) {
* @function * @function
* @api * @api
*/ */
_ol_events_condition_.always = TRUE; export const always = TRUE;
/** /**
@@ -60,7 +59,7 @@ _ol_events_condition_.always = TRUE;
* @return {boolean} True if the event is a map `click` event. * @return {boolean} True if the event is a map `click` event.
* @api * @api
*/ */
_ol_events_condition_.click = function(mapBrowserEvent) { export const click = function(mapBrowserEvent) {
return mapBrowserEvent.type == MapBrowserEventType.CLICK; return mapBrowserEvent.type == MapBrowserEventType.CLICK;
}; };
@@ -74,7 +73,7 @@ _ol_events_condition_.click = function(mapBrowserEvent) {
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event. * @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} The result. * @return {boolean} The result.
*/ */
_ol_events_condition_.mouseActionButton = function(mapBrowserEvent) { export const mouseActionButton = function(mapBrowserEvent) {
const originalEvent = mapBrowserEvent.originalEvent; const originalEvent = mapBrowserEvent.originalEvent;
return originalEvent.button == 0 && return originalEvent.button == 0 &&
!(WEBKIT && MAC && originalEvent.ctrlKey); !(WEBKIT && MAC && originalEvent.ctrlKey);
@@ -89,7 +88,7 @@ _ol_events_condition_.mouseActionButton = function(mapBrowserEvent) {
* @function * @function
* @api * @api
*/ */
_ol_events_condition_.never = FALSE; export const never = FALSE;
/** /**
@@ -100,7 +99,7 @@ _ol_events_condition_.never = FALSE;
* @return {boolean} True if the browser event is a `pointermove` event. * @return {boolean} True if the browser event is a `pointermove` event.
* @api * @api
*/ */
_ol_events_condition_.pointerMove = function(mapBrowserEvent) { export const pointerMove = function(mapBrowserEvent) {
return mapBrowserEvent.type == 'pointermove'; return mapBrowserEvent.type == 'pointermove';
}; };
@@ -112,7 +111,7 @@ _ol_events_condition_.pointerMove = function(mapBrowserEvent) {
* @return {boolean} True if the event is a map `singleclick` event. * @return {boolean} True if the event is a map `singleclick` event.
* @api * @api
*/ */
_ol_events_condition_.singleClick = function(mapBrowserEvent) { export const singleClick = function(mapBrowserEvent) {
return mapBrowserEvent.type == MapBrowserEventType.SINGLECLICK; return mapBrowserEvent.type == MapBrowserEventType.SINGLECLICK;
}; };
@@ -124,7 +123,7 @@ _ol_events_condition_.singleClick = function(mapBrowserEvent) {
* @return {boolean} True if the event is a map `dblclick` event. * @return {boolean} True if the event is a map `dblclick` event.
* @api * @api
*/ */
_ol_events_condition_.doubleClick = function(mapBrowserEvent) { export const doubleClick = function(mapBrowserEvent) {
return mapBrowserEvent.type == MapBrowserEventType.DBLCLICK; return mapBrowserEvent.type == MapBrowserEventType.DBLCLICK;
}; };
@@ -137,7 +136,7 @@ _ol_events_condition_.doubleClick = function(mapBrowserEvent) {
* @return {boolean} True only if there no modifier keys are pressed. * @return {boolean} True only if there no modifier keys are pressed.
* @api * @api
*/ */
_ol_events_condition_.noModifierKeys = function(mapBrowserEvent) { export const noModifierKeys = function(mapBrowserEvent) {
const originalEvent = mapBrowserEvent.originalEvent; const originalEvent = mapBrowserEvent.originalEvent;
return ( return (
!originalEvent.altKey && !originalEvent.altKey &&
@@ -155,7 +154,7 @@ _ol_events_condition_.noModifierKeys = function(mapBrowserEvent) {
* @return {boolean} True if only the platform modifier key is pressed. * @return {boolean} True if only the platform modifier key is pressed.
* @api * @api
*/ */
_ol_events_condition_.platformModifierKeyOnly = function(mapBrowserEvent) { export const platformModifierKeyOnly = function(mapBrowserEvent) {
const originalEvent = mapBrowserEvent.originalEvent; const originalEvent = mapBrowserEvent.originalEvent;
return !originalEvent.altKey && return !originalEvent.altKey &&
(MAC ? originalEvent.metaKey : originalEvent.ctrlKey) && (MAC ? originalEvent.metaKey : originalEvent.ctrlKey) &&
@@ -171,7 +170,7 @@ _ol_events_condition_.platformModifierKeyOnly = function(mapBrowserEvent) {
* @return {boolean} True if only the shift key is pressed. * @return {boolean} True if only the shift key is pressed.
* @api * @api
*/ */
_ol_events_condition_.shiftKeyOnly = function(mapBrowserEvent) { export const shiftKeyOnly = function(mapBrowserEvent) {
const originalEvent = mapBrowserEvent.originalEvent; const originalEvent = mapBrowserEvent.originalEvent;
return ( return (
!originalEvent.altKey && !originalEvent.altKey &&
@@ -188,7 +187,7 @@ _ol_events_condition_.shiftKeyOnly = function(mapBrowserEvent) {
* @return {boolean} True only if the target element is not editable. * @return {boolean} True only if the target element is not editable.
* @api * @api
*/ */
_ol_events_condition_.targetNotEditable = function(mapBrowserEvent) { export const targetNotEditable = function(mapBrowserEvent) {
const target = mapBrowserEvent.originalEvent.target; const target = mapBrowserEvent.originalEvent.target;
const tagName = target.tagName; const tagName = target.tagName;
return ( return (
@@ -205,7 +204,7 @@ _ol_events_condition_.targetNotEditable = function(mapBrowserEvent) {
* @return {boolean} True if the event originates from a mouse device. * @return {boolean} True if the event originates from a mouse device.
* @api * @api
*/ */
_ol_events_condition_.mouseOnly = function(mapBrowserEvent) { export const mouseOnly = function(mapBrowserEvent) {
assert(mapBrowserEvent.pointerEvent, 56); // mapBrowserEvent must originate from a pointer event assert(mapBrowserEvent.pointerEvent, 56); // mapBrowserEvent must originate from a pointer event
// see http://www.w3.org/TR/pointerevents/#widl-PointerEvent-pointerType // see http://www.w3.org/TR/pointerevents/#widl-PointerEvent-pointerType
return /** @type {ol.MapBrowserEvent} */ (mapBrowserEvent).pointerEvent.pointerType == 'mouse'; return /** @type {ol.MapBrowserEvent} */ (mapBrowserEvent).pointerEvent.pointerType == 'mouse';
@@ -221,8 +220,7 @@ _ol_events_condition_.mouseOnly = function(mapBrowserEvent) {
* @return {boolean} True if the event originates from a primary pointer. * @return {boolean} True if the event originates from a primary pointer.
* @api * @api
*/ */
_ol_events_condition_.primaryAction = function(mapBrowserEvent) { export const primaryAction = function(mapBrowserEvent) {
const pointerEvent = mapBrowserEvent.pointerEvent; const pointerEvent = mapBrowserEvent.pointerEvent;
return pointerEvent.isPrimary && pointerEvent.button === 0; return pointerEvent.isPrimary && pointerEvent.button === 0;
}; };
export default _ol_events_condition_;
+6 -7
View File
@@ -4,7 +4,7 @@
// FIXME draw drag box // FIXME draw drag box
import Event from '../events/Event.js'; import Event from '../events/Event.js';
import {inherits, nullFunction} from '../index.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 PointerInteraction from '../interaction/Pointer.js';
import _ol_render_Box_ from '../render/Box.js'; import _ol_render_Box_ from '../render/Box.js';
@@ -57,8 +57,7 @@ const DragBox = function(opt_options) {
* @private * @private
* @type {ol.EventsConditionType} * @type {ol.EventsConditionType}
*/ */
this.condition_ = options.condition ? this.condition_ = options.condition ? options.condition : always;
options.condition : _ol_events_condition_.always;
/** /**
* @private * @private
@@ -94,7 +93,7 @@ DragBox.defaultBoxEndCondition = function(mapBrowserEvent, startPixel, endPixel)
* @private * @private
*/ */
DragBox.handleDragEvent_ = function(mapBrowserEvent) { DragBox.handleDragEvent_ = function(mapBrowserEvent) {
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) { if (!mouseOnly(mapBrowserEvent)) {
return; return;
} }
@@ -131,7 +130,7 @@ DragBox.prototype.onBoxEnd = nullFunction;
* @private * @private
*/ */
DragBox.handleUpEvent_ = function(mapBrowserEvent) { DragBox.handleUpEvent_ = function(mapBrowserEvent) {
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) { if (!mouseOnly(mapBrowserEvent)) {
return true; return true;
} }
@@ -154,11 +153,11 @@ DragBox.handleUpEvent_ = function(mapBrowserEvent) {
* @private * @private
*/ */
DragBox.handleDownEvent_ = function(mapBrowserEvent) { DragBox.handleDownEvent_ = function(mapBrowserEvent) {
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) { if (!mouseOnly(mapBrowserEvent)) {
return false; return false;
} }
if (_ol_events_condition_.mouseActionButton(mapBrowserEvent) && if (mouseActionButton(mapBrowserEvent) &&
this.condition_(mapBrowserEvent)) { this.condition_(mapBrowserEvent)) {
this.startPixel_ = mapBrowserEvent.pixel; this.startPixel_ = mapBrowserEvent.pixel;
this.box_.setMap(mapBrowserEvent.map); this.box_.setMap(mapBrowserEvent.map);
+2 -3
View File
@@ -5,7 +5,7 @@ import {inherits} from '../index.js';
import ViewHint from '../ViewHint.js'; import ViewHint from '../ViewHint.js';
import _ol_coordinate_ from '../coordinate.js'; import _ol_coordinate_ from '../coordinate.js';
import {easeOut} from '../easing.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 {FALSE} from '../functions.js';
import PointerInteraction from '../interaction/Pointer.js'; import PointerInteraction from '../interaction/Pointer.js';
@@ -48,8 +48,7 @@ const DragPan = function(opt_options) {
* @private * @private
* @type {ol.EventsConditionType} * @type {ol.EventsConditionType}
*/ */
this.condition_ = options.condition ? this.condition_ = options.condition ? options.condition : noModifierKeys;
options.condition : _ol_events_condition_.noModifierKeys;
/** /**
* @private * @private
+6 -8
View File
@@ -4,7 +4,7 @@
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import RotationConstraint from '../RotationConstraint.js'; import RotationConstraint from '../RotationConstraint.js';
import ViewHint from '../ViewHint.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 {FALSE} from '../functions.js';
import Interaction from '../interaction/Interaction.js'; import Interaction from '../interaction/Interaction.js';
import PointerInteraction from '../interaction/Pointer.js'; import PointerInteraction from '../interaction/Pointer.js';
@@ -36,8 +36,7 @@ const DragRotate = function(opt_options) {
* @private * @private
* @type {ol.EventsConditionType} * @type {ol.EventsConditionType}
*/ */
this.condition_ = options.condition ? this.condition_ = options.condition ? options.condition : altShiftKeysOnly;
options.condition : _ol_events_condition_.altShiftKeysOnly;
/** /**
* @private * @private
@@ -61,7 +60,7 @@ inherits(DragRotate, PointerInteraction);
* @private * @private
*/ */
DragRotate.handleDragEvent_ = function(mapBrowserEvent) { DragRotate.handleDragEvent_ = function(mapBrowserEvent) {
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) { if (!mouseOnly(mapBrowserEvent)) {
return; return;
} }
@@ -91,7 +90,7 @@ DragRotate.handleDragEvent_ = function(mapBrowserEvent) {
* @private * @private
*/ */
DragRotate.handleUpEvent_ = function(mapBrowserEvent) { DragRotate.handleUpEvent_ = function(mapBrowserEvent) {
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) { if (!mouseOnly(mapBrowserEvent)) {
return true; return true;
} }
@@ -112,12 +111,11 @@ DragRotate.handleUpEvent_ = function(mapBrowserEvent) {
* @private * @private
*/ */
DragRotate.handleDownEvent_ = function(mapBrowserEvent) { DragRotate.handleDownEvent_ = function(mapBrowserEvent) {
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) { if (!mouseOnly(mapBrowserEvent)) {
return false; return false;
} }
if (_ol_events_condition_.mouseActionButton(mapBrowserEvent) && if (mouseActionButton(mapBrowserEvent) && this.condition_(mapBrowserEvent)) {
this.condition_(mapBrowserEvent)) {
const map = mapBrowserEvent.map; const map = mapBrowserEvent.map;
map.getView().setHint(ViewHint.INTERACTING, 1); map.getView().setHint(ViewHint.INTERACTING, 1);
this.lastAngle_ = undefined; this.lastAngle_ = undefined;
+5 -6
View File
@@ -4,7 +4,7 @@
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import RotationConstraint from '../RotationConstraint.js'; import RotationConstraint from '../RotationConstraint.js';
import ViewHint from '../ViewHint.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 Interaction from '../interaction/Interaction.js';
import PointerInteraction from '../interaction/Pointer.js'; import PointerInteraction from '../interaction/Pointer.js';
@@ -37,8 +37,7 @@ const DragRotateAndZoom = function(opt_options) {
* @private * @private
* @type {ol.EventsConditionType} * @type {ol.EventsConditionType}
*/ */
this.condition_ = options.condition ? this.condition_ = options.condition ? options.condition : shiftKeyOnly;
options.condition : _ol_events_condition_.shiftKeyOnly;
/** /**
* @private * @private
@@ -75,7 +74,7 @@ inherits(DragRotateAndZoom, PointerInteraction);
* @private * @private
*/ */
DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) { DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) {
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) { if (!mouseOnly(mapBrowserEvent)) {
return; return;
} }
@@ -111,7 +110,7 @@ DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) {
* @private * @private
*/ */
DragRotateAndZoom.handleUpEvent_ = function(mapBrowserEvent) { DragRotateAndZoom.handleUpEvent_ = function(mapBrowserEvent) {
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) { if (!mouseOnly(mapBrowserEvent)) {
return true; return true;
} }
@@ -134,7 +133,7 @@ DragRotateAndZoom.handleUpEvent_ = function(mapBrowserEvent) {
* @private * @private
*/ */
DragRotateAndZoom.handleDownEvent_ = function(mapBrowserEvent) { DragRotateAndZoom.handleDownEvent_ = function(mapBrowserEvent) {
if (!_ol_events_condition_.mouseOnly(mapBrowserEvent)) { if (!mouseOnly(mapBrowserEvent)) {
return false; return false;
} }
+2 -3
View File
@@ -3,7 +3,7 @@
*/ */
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import {easeOut} from '../easing.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 {createOrUpdateFromCoordinates, getBottomLeft, getCenter, getTopRight, scaleFromCenter} from '../extent.js';
import DragBox from '../interaction/DragBox.js'; import DragBox from '../interaction/DragBox.js';
@@ -24,8 +24,7 @@ import DragBox from '../interaction/DragBox.js';
const DragZoom = function(opt_options) { const DragZoom = function(opt_options) {
const options = opt_options ? opt_options : {}; const options = opt_options ? opt_options : {};
const condition = options.condition ? const condition = options.condition ? options.condition : shiftKeyOnly;
options.condition : _ol_events_condition_.shiftKeyOnly;
/** /**
* @private * @private
+4 -5
View File
@@ -10,7 +10,7 @@ import BaseObject from '../Object.js';
import _ol_coordinate_ from '../coordinate.js'; import _ol_coordinate_ from '../coordinate.js';
import {listen} from '../events.js'; import {listen} from '../events.js';
import Event from '../events/Event.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 {boundingExtent, getBottomLeft, getBottomRight, getTopLeft, getTopRight} from '../extent.js';
import {TRUE, FALSE} from '../functions.js'; import {TRUE, FALSE} from '../functions.js';
import Circle from '../geom/Circle.js'; import Circle from '../geom/Circle.js';
@@ -291,8 +291,7 @@ const Draw = function(options) {
* @private * @private
* @type {ol.EventsConditionType} * @type {ol.EventsConditionType}
*/ */
this.condition_ = options.condition ? this.condition_ = options.condition ? options.condition : noModifierKeys;
options.condition : _ol_events_condition_.noModifierKeys;
/** /**
* @private * @private
@@ -300,10 +299,10 @@ const Draw = function(options) {
*/ */
this.freehandCondition_; this.freehandCondition_;
if (options.freehand) { if (options.freehand) {
this.freehandCondition_ = _ol_events_condition_.always; this.freehandCondition_ = always;
} else { } else {
this.freehandCondition_ = options.freehandCondition ? this.freehandCondition_ = options.freehandCondition ?
options.freehandCondition : _ol_events_condition_.shiftKeyOnly; options.freehandCondition : shiftKeyOnly;
} }
listen(this, listen(this,
+3 -3
View File
@@ -5,7 +5,7 @@ import {inherits} from '../index.js';
import _ol_coordinate_ from '../coordinate.js'; import _ol_coordinate_ from '../coordinate.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import KeyCode from '../events/KeyCode.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'; import Interaction from '../interaction/Interaction.js';
/** /**
@@ -39,8 +39,8 @@ const KeyboardPan = function(opt_options) {
* @return {boolean} Combined condition result. * @return {boolean} Combined condition result.
*/ */
this.defaultCondition_ = function(mapBrowserEvent) { this.defaultCondition_ = function(mapBrowserEvent) {
return _ol_events_condition_.noModifierKeys(mapBrowserEvent) && return noModifierKeys(mapBrowserEvent) &&
_ol_events_condition_.targetNotEditable(mapBrowserEvent); targetNotEditable(mapBrowserEvent);
}; };
/** /**
+2 -3
View File
@@ -3,7 +3,7 @@
*/ */
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import EventType from '../events/EventType.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'; import Interaction from '../interaction/Interaction.js';
/** /**
@@ -35,8 +35,7 @@ const KeyboardZoom = function(opt_options) {
* @private * @private
* @type {ol.EventsConditionType} * @type {ol.EventsConditionType}
*/ */
this.condition_ = options.condition ? options.condition : this.condition_ = options.condition ? options.condition : targetNotEditable;
_ol_events_condition_.targetNotEditable;
/** /**
* @private * @private
+4 -6
View File
@@ -12,7 +12,7 @@ import _ol_coordinate_ from '../coordinate.js';
import {listen, unlisten} from '../events.js'; import {listen, unlisten} from '../events.js';
import Event from '../events/Event.js'; import Event from '../events/Event.js';
import EventType from '../events/EventType.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 {boundingExtent, buffer, createOrUpdateFromCoordinate} from '../extent.js';
import GeometryType from '../geom/GeometryType.js'; import GeometryType from '../geom/GeometryType.js';
import Point from '../geom/Point.js'; import Point from '../geom/Point.js';
@@ -56,8 +56,7 @@ const Modify = function(options) {
* @private * @private
* @type {ol.EventsConditionType} * @type {ol.EventsConditionType}
*/ */
this.condition_ = options.condition ? this.condition_ = options.condition ? options.condition : primaryAction;
options.condition : _ol_events_condition_.primaryAction;
/** /**
@@ -66,8 +65,7 @@ const Modify = function(options) {
* @return {boolean} Combined condition result. * @return {boolean} Combined condition result.
*/ */
this.defaultDeleteCondition_ = function(mapBrowserEvent) { this.defaultDeleteCondition_ = function(mapBrowserEvent) {
return _ol_events_condition_.altKeyOnly(mapBrowserEvent) && return altKeyOnly(mapBrowserEvent) && singleClick(mapBrowserEvent);
_ol_events_condition_.singleClick(mapBrowserEvent);
}; };
/** /**
@@ -82,7 +80,7 @@ const Modify = function(options) {
* @private * @private
*/ */
this.insertVertexCondition_ = options.insertVertexCondition ? this.insertVertexCondition_ = options.insertVertexCondition ?
options.insertVertexCondition : _ol_events_condition_.always; options.insertVertexCondition : always;
/** /**
* Editing vertex. * Editing vertex.
+2 -2
View File
@@ -3,7 +3,7 @@
*/ */
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import ViewHint from '../ViewHint.js'; import ViewHint from '../ViewHint.js';
import condition from '../events/condition.js'; import {always} from '../events/condition.js';
import {easeOut} from '../easing.js'; import {easeOut} from '../easing.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import {DEVICE_PIXEL_RATIO, FIREFOX, SAFARI} from '../has.js'; import {DEVICE_PIXEL_RATIO, FIREFOX, SAFARI} from '../has.js';
@@ -68,7 +68,7 @@ const MouseWheelZoom = function(opt_options) {
* @private * @private
* @type {ol.EventsConditionType} * @type {ol.EventsConditionType}
*/ */
this.condition_ = options.condition ? options.condition : condition.always; this.condition_ = options.condition ? options.condition : always;
/** /**
* @private * @private
+6 -10
View File
@@ -6,7 +6,7 @@ import CollectionEventType from '../CollectionEventType.js';
import {extend, includes} from '../array.js'; import {extend, includes} from '../array.js';
import {listen} from '../events.js'; import {listen} from '../events.js';
import Event from '../events/Event.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 {TRUE} from '../functions.js';
import GeometryType from '../geom/GeometryType.js'; import GeometryType from '../geom/GeometryType.js';
import Interaction from '../interaction/Interaction.js'; import Interaction from '../interaction/Interaction.js';
@@ -45,29 +45,25 @@ const Select = function(opt_options) {
* @private * @private
* @type {ol.EventsConditionType} * @type {ol.EventsConditionType}
*/ */
this.condition_ = options.condition ? this.condition_ = options.condition ? options.condition : singleClick;
options.condition : _ol_events_condition_.singleClick;
/** /**
* @private * @private
* @type {ol.EventsConditionType} * @type {ol.EventsConditionType}
*/ */
this.addCondition_ = options.addCondition ? this.addCondition_ = options.addCondition ? options.addCondition : never;
options.addCondition : _ol_events_condition_.never;
/** /**
* @private * @private
* @type {ol.EventsConditionType} * @type {ol.EventsConditionType}
*/ */
this.removeCondition_ = options.removeCondition ? this.removeCondition_ = options.removeCondition ? options.removeCondition : never;
options.removeCondition : _ol_events_condition_.never;
/** /**
* @private * @private
* @type {ol.EventsConditionType} * @type {ol.EventsConditionType}
*/ */
this.toggleCondition_ = options.toggleCondition ? this.toggleCondition_ = options.toggleCondition ? options.toggleCondition : shiftKeyOnly;
options.toggleCondition : _ol_events_condition_.shiftKeyOnly;
/** /**
* @private * @private
@@ -283,7 +279,7 @@ Select.handleEvent = function(mapBrowserEvent) {
new Select.Event(Select.EventType_.SELECT, new Select.Event(Select.EventType_.SELECT,
selected, deselected, mapBrowserEvent)); selected, deselected, mapBrowserEvent));
} }
return _ol_events_condition_.pointerMove(mapBrowserEvent); return pointerMove(mapBrowserEvent);
}; };
+2 -2
View File
@@ -4,7 +4,7 @@ import MapBrowserPointerEvent from '../../../../src/ol/MapBrowserPointerEvent.js
import View from '../../../../src/ol/View.js'; import View from '../../../../src/ol/View.js';
import {equals} from '../../../../src/ol/array.js'; import {equals} from '../../../../src/ol/array.js';
import {listen} from '../../../../src/ol/events.js'; import {listen} from '../../../../src/ol/events.js';
import _ol_events_condition_ from '../../../../src/ol/events/condition.js'; import {always} from '../../../../src/ol/events/condition.js';
import Circle from '../../../../src/ol/geom/Circle.js'; import Circle from '../../../../src/ol/geom/Circle.js';
import LineString from '../../../../src/ol/geom/LineString.js'; import LineString from '../../../../src/ol/geom/LineString.js';
import MultiLineString from '../../../../src/ol/geom/MultiLineString.js'; import MultiLineString from '../../../../src/ol/geom/MultiLineString.js';
@@ -884,7 +884,7 @@ describe('ol.interaction.Draw', function() {
it('supports freehand drawing for circles', function() { it('supports freehand drawing for circles', function() {
draw.freehand_ = true; draw.freehand_ = true;
draw.freehandCondition_ = _ol_events_condition_.always; draw.freehandCondition_ = always;
// no feture created when not moved // no feture created when not moved
simulateEvent('pointermove', 10, 20); simulateEvent('pointermove', 10, 20);
+2 -2
View File
@@ -4,7 +4,7 @@ import Map from '../../../../src/ol/Map.js';
import MapBrowserPointerEvent from '../../../../src/ol/MapBrowserPointerEvent.js'; import MapBrowserPointerEvent from '../../../../src/ol/MapBrowserPointerEvent.js';
import View from '../../../../src/ol/View.js'; import View from '../../../../src/ol/View.js';
import {getListeners} from '../../../../src/ol/events.js'; import {getListeners} from '../../../../src/ol/events.js';
import _ol_events_condition_ from '../../../../src/ol/events/condition.js'; import {doubleClick} from '../../../../src/ol/events/condition.js';
import Circle from '../../../../src/ol/geom/Circle.js'; import Circle from '../../../../src/ol/geom/Circle.js';
import LineString from '../../../../src/ol/geom/LineString.js'; import LineString from '../../../../src/ol/geom/LineString.js';
import Point from '../../../../src/ol/geom/Point.js'; import Point from '../../../../src/ol/geom/Point.js';
@@ -524,7 +524,7 @@ describe('ol.interaction.Modify', function() {
beforeEach(function() { beforeEach(function() {
modify = new Modify({ modify = new Modify({
features: new Collection(features), features: new Collection(features),
deleteCondition: _ol_events_condition_.doubleClick deleteCondition: doubleClick
}); });
map.addInteraction(modify); map.addInteraction(modify);