Named exports from ol/events

This commit is contained in:
Tim Schaub
2018-01-24 10:09:57 -07:00
parent 1786bbbe80
commit 7e7631c42a
74 changed files with 437 additions and 445 deletions

View File

@@ -5,7 +5,7 @@
import {inherits} from '../index.js';
import {TRUE} from '../functions.js';
import _ol_events_ from '../events.js';
import {listen, unlistenByKey} from '../events.js';
import Event from '../events/Event.js';
import EventType from '../events/EventType.js';
import Interaction from '../interaction/Interaction.js';
@@ -159,13 +159,13 @@ DragAndDrop.prototype.registerListeners_ = function() {
if (map) {
const dropArea = this.target ? this.target : map.getViewport();
this.dropListenKeys_ = [
_ol_events_.listen(dropArea, EventType.DROP,
listen(dropArea, EventType.DROP,
DragAndDrop.handleDrop_, this),
_ol_events_.listen(dropArea, EventType.DRAGENTER,
listen(dropArea, EventType.DRAGENTER,
DragAndDrop.handleStop_, this),
_ol_events_.listen(dropArea, EventType.DRAGOVER,
listen(dropArea, EventType.DRAGOVER,
DragAndDrop.handleStop_, this),
_ol_events_.listen(dropArea, EventType.DROP,
listen(dropArea, EventType.DROP,
DragAndDrop.handleStop_, this)
];
}
@@ -218,7 +218,7 @@ DragAndDrop.prototype.tryReadFeatures_ = function(format, text, options) {
*/
DragAndDrop.prototype.unregisterListeners_ = function() {
if (this.dropListenKeys_) {
this.dropListenKeys_.forEach(_ol_events_.unlistenByKey);
this.dropListenKeys_.forEach(unlistenByKey);
this.dropListenKeys_ = null;
}
};

View File

@@ -8,7 +8,7 @@ import MapBrowserEventType from '../MapBrowserEventType.js';
import MapBrowserPointerEvent from '../MapBrowserPointerEvent.js';
import BaseObject from '../Object.js';
import _ol_coordinate_ from '../coordinate.js';
import _ol_events_ from '../events.js';
import {listen} from '../events.js';
import Event from '../events/Event.js';
import _ol_events_condition_ from '../events/condition.js';
import {boundingExtent, getBottomLeft, getBottomRight, getTopLeft, getTopRight} from '../extent.js';
@@ -306,7 +306,7 @@ const Draw = function(options) {
options.freehandCondition : _ol_events_condition_.shiftKeyOnly;
}
_ol_events_.listen(this,
listen(this,
BaseObject.getChangeEventType(InteractionProperty.ACTIVE),
this.updateState_, this);

View File

@@ -9,7 +9,7 @@ import MapBrowserEventType from '../MapBrowserEventType.js';
import MapBrowserPointerEvent from '../MapBrowserPointerEvent.js';
import {equals} from '../array.js';
import _ol_coordinate_ from '../coordinate.js';
import _ol_events_ from '../events.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';
@@ -196,9 +196,9 @@ const Modify = function(options) {
if (options.source) {
this.source_ = options.source;
features = new Collection(this.source_.getFeatures());
_ol_events_.listen(this.source_, VectorEventType.ADDFEATURE,
listen(this.source_, VectorEventType.ADDFEATURE,
this.handleSourceAdd_, this);
_ol_events_.listen(this.source_, VectorEventType.REMOVEFEATURE,
listen(this.source_, VectorEventType.REMOVEFEATURE,
this.handleSourceRemove_, this);
} else {
features = options.features;
@@ -214,9 +214,9 @@ const Modify = function(options) {
this.features_ = features;
this.features_.forEach(this.addFeature_.bind(this));
_ol_events_.listen(this.features_, CollectionEventType.ADD,
listen(this.features_, CollectionEventType.ADD,
this.handleFeatureAdd_, this);
_ol_events_.listen(this.features_, CollectionEventType.REMOVE,
listen(this.features_, CollectionEventType.REMOVE,
this.handleFeatureRemove_, this);
/**
@@ -256,7 +256,7 @@ Modify.prototype.addFeature_ = function(feature) {
if (map && map.isRendered() && this.getActive()) {
this.handlePointerAtPixel_(this.lastPixel_, map);
}
_ol_events_.listen(feature, EventType.CHANGE,
listen(feature, EventType.CHANGE,
this.handleFeatureChange_, this);
};
@@ -286,7 +286,7 @@ Modify.prototype.removeFeature_ = function(feature) {
this.overlay_.getSource().removeFeature(this.vertexFeature_);
this.vertexFeature_ = null;
}
_ol_events_.unlisten(feature, EventType.CHANGE,
unlisten(feature, EventType.CHANGE,
this.handleFeatureChange_, this);
};

View File

@@ -4,7 +4,7 @@
import {getUid, inherits} from '../index.js';
import CollectionEventType from '../CollectionEventType.js';
import {extend, includes} from '../array.js';
import _ol_events_ from '../events.js';
import {listen} from '../events.js';
import Event from '../events/Event.js';
import _ol_events_condition_ from '../events/condition.js';
import {TRUE} from '../functions.js';
@@ -135,9 +135,9 @@ const Select = function(opt_options) {
this.featureLayerAssociation_ = {};
const features = this.featureOverlay_.getSource().getFeaturesCollection();
_ol_events_.listen(features, CollectionEventType.ADD,
listen(features, CollectionEventType.ADD,
this.addFeature_, this);
_ol_events_.listen(features, CollectionEventType.REMOVE,
listen(features, CollectionEventType.REMOVE,
this.removeFeature_, this);
};

View File

@@ -5,7 +5,7 @@ import {getUid, inherits} from '../index.js';
import Collection from '../Collection.js';
import CollectionEventType from '../CollectionEventType.js';
import _ol_coordinate_ from '../coordinate.js';
import _ol_events_ from '../events.js';
import {listen, unlistenByKey} from '../events.js';
import EventType from '../events/EventType.js';
import {boundingExtent, createEmpty} from '../extent.js';
import {TRUE, FALSE} from '../functions.js';
@@ -160,7 +160,7 @@ inherits(Snap, PointerInteraction);
* @api
*/
Snap.prototype.addFeature = function(feature, opt_listen) {
const listen = opt_listen !== undefined ? opt_listen : true;
const register = opt_listen !== undefined ? opt_listen : true;
const feature_uid = getUid(feature);
const geometry = feature.getGeometry();
if (geometry) {
@@ -171,8 +171,8 @@ Snap.prototype.addFeature = function(feature, opt_listen) {
}
}
if (listen) {
this.featureChangeListenerKeys_[feature_uid] = _ol_events_.listen(
if (register) {
this.featureChangeListenerKeys_[feature_uid] = listen(
feature,
EventType.CHANGE,
this.handleFeatureChange_, this);
@@ -268,7 +268,7 @@ Snap.prototype.handleFeatureChange_ = function(evt) {
* @api
*/
Snap.prototype.removeFeature = function(feature, opt_unlisten) {
const unlisten = opt_unlisten !== undefined ? opt_unlisten : true;
const unregister = opt_unlisten !== undefined ? opt_unlisten : true;
const feature_uid = getUid(feature);
const extent = this.indexedFeaturesExtents_[feature_uid];
if (extent) {
@@ -284,8 +284,8 @@ Snap.prototype.removeFeature = function(feature, opt_unlisten) {
}
}
if (unlisten) {
_ol_events_.unlistenByKey(this.featureChangeListenerKeys_[feature_uid]);
if (unregister) {
unlistenByKey(this.featureChangeListenerKeys_[feature_uid]);
delete this.featureChangeListenerKeys_[feature_uid];
}
};
@@ -300,7 +300,7 @@ Snap.prototype.setMap = function(map) {
const features = this.getFeatures_();
if (currentMap) {
keys.forEach(_ol_events_.unlistenByKey);
keys.forEach(unlistenByKey);
keys.length = 0;
features.forEach(this.forEachFeatureRemove_.bind(this));
}
@@ -309,16 +309,16 @@ Snap.prototype.setMap = function(map) {
if (map) {
if (this.features_) {
keys.push(
_ol_events_.listen(this.features_, CollectionEventType.ADD,
listen(this.features_, CollectionEventType.ADD,
this.handleFeatureAdd_, this),
_ol_events_.listen(this.features_, CollectionEventType.REMOVE,
listen(this.features_, CollectionEventType.REMOVE,
this.handleFeatureRemove_, this)
);
} else if (this.source_) {
keys.push(
_ol_events_.listen(this.source_, VectorEventType.ADDFEATURE,
listen(this.source_, VectorEventType.ADDFEATURE,
this.handleFeatureAdd_, this),
_ol_events_.listen(this.source_, VectorEventType.REMOVEFEATURE,
listen(this.source_, VectorEventType.REMOVEFEATURE,
this.handleFeatureRemove_, this)
);
}

View File

@@ -4,7 +4,7 @@
import {inherits} from '../index.js';
import Collection from '../Collection.js';
import BaseObject from '../Object.js';
import _ol_events_ from '../events.js';
import {listen} from '../events.js';
import Event from '../events/Event.js';
import {TRUE} from '../functions.js';
import {includes} from '../array.js';
@@ -79,7 +79,7 @@ const Translate = function(opt_options) {
*/
this.lastFeature_ = null;
_ol_events_.listen(this,
listen(this,
BaseObject.getChangeEventType(InteractionProperty.ACTIVE),
this.handleActiveChanged_, this);