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
+12 -12
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)
);
}