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

@@ -7,7 +7,7 @@ import CollectionEventType from '../CollectionEventType.js';
import BaseObject from '../Object.js';
import ObjectEventType from '../ObjectEventType.js';
import {assert} from '../asserts.js';
import _ol_events_ from '../events.js';
import {listen, unlistenByKey} from '../events.js';
import EventType from '../events/EventType.js';
import {getIntersection} from '../extent.js';
import BaseLayer from '../layer/Base.js';
@@ -57,7 +57,7 @@ const LayerGroup = function(opt_options) {
*/
this.listenerKeys_ = {};
_ol_events_.listen(this,
listen(this,
BaseObject.getChangeEventType(Property.LAYERS),
this.handleLayersChanged_, this);
@@ -93,18 +93,18 @@ LayerGroup.prototype.handleLayerChange_ = function() {
* @private
*/
LayerGroup.prototype.handleLayersChanged_ = function(event) {
this.layersListenerKeys_.forEach(_ol_events_.unlistenByKey);
this.layersListenerKeys_.forEach(unlistenByKey);
this.layersListenerKeys_.length = 0;
const layers = this.getLayers();
this.layersListenerKeys_.push(
_ol_events_.listen(layers, CollectionEventType.ADD,
listen(layers, CollectionEventType.ADD,
this.handleLayersAdd_, this),
_ol_events_.listen(layers, CollectionEventType.REMOVE,
listen(layers, CollectionEventType.REMOVE,
this.handleLayersRemove_, this));
for (const id in this.listenerKeys_) {
this.listenerKeys_[id].forEach(_ol_events_.unlistenByKey);
this.listenerKeys_[id].forEach(unlistenByKey);
}
clear(this.listenerKeys_);
@@ -112,9 +112,9 @@ LayerGroup.prototype.handleLayersChanged_ = function(event) {
for (let i = 0, ii = layersArray.length; i < ii; i++) {
const layer = layersArray[i];
this.listenerKeys_[getUid(layer).toString()] = [
_ol_events_.listen(layer, ObjectEventType.PROPERTYCHANGE,
listen(layer, ObjectEventType.PROPERTYCHANGE,
this.handleLayerChange_, this),
_ol_events_.listen(layer, EventType.CHANGE,
listen(layer, EventType.CHANGE,
this.handleLayerChange_, this)
];
}
@@ -131,9 +131,9 @@ LayerGroup.prototype.handleLayersAdd_ = function(collectionEvent) {
const layer = /** @type {ol.layer.Base} */ (collectionEvent.element);
const key = getUid(layer).toString();
this.listenerKeys_[key] = [
_ol_events_.listen(layer, ObjectEventType.PROPERTYCHANGE,
listen(layer, ObjectEventType.PROPERTYCHANGE,
this.handleLayerChange_, this),
_ol_events_.listen(layer, EventType.CHANGE,
listen(layer, EventType.CHANGE,
this.handleLayerChange_, this)
];
this.changed();
@@ -147,7 +147,7 @@ LayerGroup.prototype.handleLayersAdd_ = function(collectionEvent) {
LayerGroup.prototype.handleLayersRemove_ = function(collectionEvent) {
const layer = /** @type {ol.layer.Base} */ (collectionEvent.element);
const key = getUid(layer).toString();
this.listenerKeys_[key].forEach(_ol_events_.unlistenByKey);
this.listenerKeys_[key].forEach(unlistenByKey);
delete this.listenerKeys_[key];
this.changed();
};

View File

@@ -1,7 +1,7 @@
/**
* @module ol/layer/Heatmap
*/
import _ol_events_ from '../events.js';
import {listen} from '../events.js';
import {inherits} from '../index.js';
import BaseObject from '../Object.js';
import {createCanvasContext2D} from '../dom.js';
@@ -80,7 +80,7 @@ const Heatmap = function(opt_options) {
*/
this.styleCache_ = null;
_ol_events_.listen(this,
listen(this,
BaseObject.getChangeEventType(Property.GRADIENT),
this.handleGradientChanged_, this);
@@ -90,10 +90,10 @@ const Heatmap = function(opt_options) {
this.setRadius(options.radius !== undefined ? options.radius : 8);
_ol_events_.listen(this,
listen(this,
BaseObject.getChangeEventType(Property.BLUR),
this.handleStyleChanged_, this);
_ol_events_.listen(this,
listen(this,
BaseObject.getChangeEventType(Property.RADIUS),
this.handleStyleChanged_, this);
@@ -133,7 +133,7 @@ const Heatmap = function(opt_options) {
// The render order is not relevant for a heatmap representation.
this.setRenderOrder(null);
_ol_events_.listen(this, RenderEventType.RENDER, this.handleRender_, this);
listen(this, RenderEventType.RENDER, this.handleRender_, this);
};
inherits(Heatmap, VectorLayer);

View File

@@ -1,7 +1,7 @@
/**
* @module ol/layer/Layer
*/
import _ol_events_ from '../events.js';
import {listen, unlistenByKey} from '../events.js';
import EventType from '../events/EventType.js';
import {getUid, inherits} from '../index.js';
import BaseObject from '../Object.js';
@@ -62,7 +62,7 @@ const Layer = function(options) {
this.setMap(options.map);
}
_ol_events_.listen(this,
listen(this,
BaseObject.getChangeEventType(LayerProperty.SOURCE),
this.handleSourcePropertyChange_, this);
@@ -141,12 +141,12 @@ Layer.prototype.handleSourceChange_ = function() {
*/
Layer.prototype.handleSourcePropertyChange_ = function() {
if (this.sourceChangeKey_) {
_ol_events_.unlistenByKey(this.sourceChangeKey_);
unlistenByKey(this.sourceChangeKey_);
this.sourceChangeKey_ = null;
}
const source = this.getSource();
if (source) {
this.sourceChangeKey_ = _ol_events_.listen(source,
this.sourceChangeKey_ = listen(source,
EventType.CHANGE, this.handleSourceChange_, this);
}
this.changed();
@@ -167,18 +167,18 @@ Layer.prototype.handleSourcePropertyChange_ = function() {
*/
Layer.prototype.setMap = function(map) {
if (this.mapPrecomposeKey_) {
_ol_events_.unlistenByKey(this.mapPrecomposeKey_);
unlistenByKey(this.mapPrecomposeKey_);
this.mapPrecomposeKey_ = null;
}
if (!map) {
this.changed();
}
if (this.mapRenderKey_) {
_ol_events_.unlistenByKey(this.mapRenderKey_);
unlistenByKey(this.mapRenderKey_);
this.mapRenderKey_ = null;
}
if (map) {
this.mapPrecomposeKey_ = _ol_events_.listen(
this.mapPrecomposeKey_ = listen(
map, RenderEventType.PRECOMPOSE, function(evt) {
const layerState = this.getLayerState();
layerState.managed = false;
@@ -186,7 +186,7 @@ Layer.prototype.setMap = function(map) {
evt.frameState.layerStatesArray.push(layerState);
evt.frameState.layerStates[getUid(this)] = layerState;
}, this);
this.mapRenderKey_ = _ol_events_.listen(
this.mapRenderKey_ = listen(
this, EventType.CHANGE, map.render, map);
this.changed();
}