Named exports from ol/events
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* @module ol/Feature
|
||||
*/
|
||||
import {assert} from './asserts.js';
|
||||
import _ol_events_ from './events.js';
|
||||
import {listen, unlisten, unlistenByKey} from './events.js';
|
||||
import EventType from './events/EventType.js';
|
||||
import {inherits} from './index.js';
|
||||
import BaseObject from './Object.js';
|
||||
@@ -90,7 +90,7 @@ const Feature = function(opt_geometryOrProperties) {
|
||||
*/
|
||||
this.geometryChangeKey_ = null;
|
||||
|
||||
_ol_events_.listen(
|
||||
listen(
|
||||
this, BaseObject.getChangeEventType(this.geometryName_),
|
||||
this.handleGeometryChanged_, this);
|
||||
|
||||
@@ -205,12 +205,12 @@ Feature.prototype.handleGeometryChange_ = function() {
|
||||
*/
|
||||
Feature.prototype.handleGeometryChanged_ = function() {
|
||||
if (this.geometryChangeKey_) {
|
||||
_ol_events_.unlistenByKey(this.geometryChangeKey_);
|
||||
unlistenByKey(this.geometryChangeKey_);
|
||||
this.geometryChangeKey_ = null;
|
||||
}
|
||||
const geometry = this.getGeometry();
|
||||
if (geometry) {
|
||||
this.geometryChangeKey_ = _ol_events_.listen(geometry,
|
||||
this.geometryChangeKey_ = listen(geometry,
|
||||
EventType.CHANGE, this.handleGeometryChange_, this);
|
||||
}
|
||||
this.changed();
|
||||
@@ -269,11 +269,11 @@ Feature.prototype.setId = function(id) {
|
||||
* @api
|
||||
*/
|
||||
Feature.prototype.setGeometryName = function(name) {
|
||||
_ol_events_.unlisten(
|
||||
unlisten(
|
||||
this, BaseObject.getChangeEventType(this.geometryName_),
|
||||
this.handleGeometryChanged_, this);
|
||||
this.geometryName_ = name;
|
||||
_ol_events_.listen(
|
||||
listen(
|
||||
this, BaseObject.getChangeEventType(this.geometryName_),
|
||||
this.handleGeometryChanged_, this);
|
||||
this.handleGeometryChanged_();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {inherits} from './index.js';
|
||||
import GeolocationProperty from './GeolocationProperty.js';
|
||||
import BaseObject from './Object.js';
|
||||
import _ol_events_ from './events.js';
|
||||
import {listen} from './events.js';
|
||||
import EventType from './events/EventType.js';
|
||||
import {circular as circularPolygon} from './geom/Polygon.js';
|
||||
import _ol_has_ from './has.js';
|
||||
@@ -78,10 +78,10 @@ const Geolocation = function(opt_options) {
|
||||
*/
|
||||
this.watchId_ = undefined;
|
||||
|
||||
_ol_events_.listen(
|
||||
listen(
|
||||
this, BaseObject.getChangeEventType(GeolocationProperty.PROJECTION),
|
||||
this.handleProjectionChanged_, this);
|
||||
_ol_events_.listen(
|
||||
listen(
|
||||
this, BaseObject.getChangeEventType(GeolocationProperty.TRACKING),
|
||||
this.handleTrackingChanged_, this);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {inherits} from './index.js';
|
||||
import _ol_ImageBase_ from './ImageBase.js';
|
||||
import ImageState from './ImageState.js';
|
||||
import _ol_events_ from './events.js';
|
||||
import {listenOnce, unlistenByKey} from './events.js';
|
||||
import EventType from './events/EventType.js';
|
||||
import {getHeight} from './extent.js';
|
||||
|
||||
@@ -108,9 +108,9 @@ _ol_Image_.prototype.load = function() {
|
||||
this.state = ImageState.LOADING;
|
||||
this.changed();
|
||||
this.imageListenerKeys_ = [
|
||||
_ol_events_.listenOnce(this.image_, EventType.ERROR,
|
||||
listenOnce(this.image_, EventType.ERROR,
|
||||
this.handleImageError_, this),
|
||||
_ol_events_.listenOnce(this.image_, EventType.LOAD,
|
||||
listenOnce(this.image_, EventType.LOAD,
|
||||
this.handleImageLoad_, this)
|
||||
];
|
||||
this.imageLoadFunction_(this, this.src_);
|
||||
@@ -132,7 +132,7 @@ _ol_Image_.prototype.setImage = function(image) {
|
||||
* @private
|
||||
*/
|
||||
_ol_Image_.prototype.unlistenImage_ = function() {
|
||||
this.imageListenerKeys_.forEach(_ol_events_.unlistenByKey);
|
||||
this.imageListenerKeys_.forEach(unlistenByKey);
|
||||
this.imageListenerKeys_ = null;
|
||||
};
|
||||
export default _ol_Image_;
|
||||
|
||||
@@ -5,7 +5,7 @@ import {inherits} from './index.js';
|
||||
import Tile from './Tile.js';
|
||||
import TileState from './TileState.js';
|
||||
import {createCanvasContext2D} from './dom.js';
|
||||
import _ol_events_ from './events.js';
|
||||
import {listenOnce, unlistenByKey} from './events.js';
|
||||
import EventType from './events/EventType.js';
|
||||
|
||||
/**
|
||||
@@ -142,9 +142,9 @@ ImageTile.prototype.load = function() {
|
||||
this.state = TileState.LOADING;
|
||||
this.changed();
|
||||
this.imageListenerKeys_ = [
|
||||
_ol_events_.listenOnce(this.image_, EventType.ERROR,
|
||||
listenOnce(this.image_, EventType.ERROR,
|
||||
this.handleImageError_, this),
|
||||
_ol_events_.listenOnce(this.image_, EventType.LOAD,
|
||||
listenOnce(this.image_, EventType.LOAD,
|
||||
this.handleImageLoad_, this)
|
||||
];
|
||||
this.tileLoadFunction_(this, this.src_);
|
||||
@@ -158,7 +158,7 @@ ImageTile.prototype.load = function() {
|
||||
* @private
|
||||
*/
|
||||
ImageTile.prototype.unlistenImage_ = function() {
|
||||
this.imageListenerKeys_.forEach(_ol_events_.unlistenByKey);
|
||||
this.imageListenerKeys_.forEach(unlistenByKey);
|
||||
this.imageListenerKeys_ = null;
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import {inherits} from './index.js';
|
||||
import _ol_has_ from './has.js';
|
||||
import MapBrowserEventType from './MapBrowserEventType.js';
|
||||
import MapBrowserPointerEvent from './MapBrowserPointerEvent.js';
|
||||
import _ol_events_ from './events.js';
|
||||
import {listen, unlistenByKey} from './events.js';
|
||||
import EventTarget from './events/EventTarget.js';
|
||||
import PointerEventType from './pointer/EventType.js';
|
||||
import PointerEventHandler from './pointer/PointerEventHandler.js';
|
||||
@@ -96,7 +96,7 @@ const MapBrowserEventHandler = function(map, moveTolerance) {
|
||||
* @type {?ol.EventsKey}
|
||||
* @private
|
||||
*/
|
||||
this.pointerdownListenerKey_ = _ol_events_.listen(this.pointerEventHandler_,
|
||||
this.pointerdownListenerKey_ = listen(this.pointerEventHandler_,
|
||||
PointerEventType.POINTERDOWN,
|
||||
this.handlePointerDown_, this);
|
||||
|
||||
@@ -104,7 +104,7 @@ const MapBrowserEventHandler = function(map, moveTolerance) {
|
||||
* @type {?ol.EventsKey}
|
||||
* @private
|
||||
*/
|
||||
this.relayedListenerKey_ = _ol_events_.listen(this.pointerEventHandler_,
|
||||
this.relayedListenerKey_ = listen(this.pointerEventHandler_,
|
||||
PointerEventType.POINTERMOVE,
|
||||
this.relayEvent_, this);
|
||||
|
||||
@@ -180,7 +180,7 @@ MapBrowserEventHandler.prototype.handlePointerUp_ = function(pointerEvent) {
|
||||
}
|
||||
|
||||
if (this.activePointers_ === 0) {
|
||||
this.dragListenerKeys_.forEach(_ol_events_.unlistenByKey);
|
||||
this.dragListenerKeys_.forEach(unlistenByKey);
|
||||
this.dragListenerKeys_.length = 0;
|
||||
this.dragging_ = false;
|
||||
this.down_ = null;
|
||||
@@ -221,10 +221,10 @@ MapBrowserEventHandler.prototype.handlePointerDown_ = function(pointerEvent) {
|
||||
new PointerEventHandler(document);
|
||||
|
||||
this.dragListenerKeys_.push(
|
||||
_ol_events_.listen(this.documentPointerEventHandler_,
|
||||
listen(this.documentPointerEventHandler_,
|
||||
MapBrowserEventType.POINTERMOVE,
|
||||
this.handlePointerMove_, this),
|
||||
_ol_events_.listen(this.documentPointerEventHandler_,
|
||||
listen(this.documentPointerEventHandler_,
|
||||
MapBrowserEventType.POINTERUP,
|
||||
this.handlePointerUp_, this),
|
||||
/* Note that the listener for `pointercancel is set up on
|
||||
@@ -240,7 +240,7 @@ MapBrowserEventHandler.prototype.handlePointerDown_ = function(pointerEvent) {
|
||||
* only receive a `touchcancel` from `pointerEventHandler_`, because it is
|
||||
* only registered there.
|
||||
*/
|
||||
_ol_events_.listen(this.pointerEventHandler_,
|
||||
listen(this.pointerEventHandler_,
|
||||
MapBrowserEventType.POINTERCANCEL,
|
||||
this.handlePointerUp_, this)
|
||||
);
|
||||
@@ -301,15 +301,15 @@ MapBrowserEventHandler.prototype.isMoving_ = function(pointerEvent) {
|
||||
*/
|
||||
MapBrowserEventHandler.prototype.disposeInternal = function() {
|
||||
if (this.relayedListenerKey_) {
|
||||
_ol_events_.unlistenByKey(this.relayedListenerKey_);
|
||||
unlistenByKey(this.relayedListenerKey_);
|
||||
this.relayedListenerKey_ = null;
|
||||
}
|
||||
if (this.pointerdownListenerKey_) {
|
||||
_ol_events_.unlistenByKey(this.pointerdownListenerKey_);
|
||||
unlistenByKey(this.pointerdownListenerKey_);
|
||||
this.pointerdownListenerKey_ = null;
|
||||
}
|
||||
|
||||
this.dragListenerKeys_.forEach(_ol_events_.unlistenByKey);
|
||||
this.dragListenerKeys_.forEach(unlistenByKey);
|
||||
this.dragListenerKeys_.length = 0;
|
||||
|
||||
if (this.documentPointerEventHandler_) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/Observable
|
||||
*/
|
||||
import {inherits} from './index.js';
|
||||
import _ol_events_ from './events.js';
|
||||
import {listen, unlistenByKey, unlisten, listenOnce} from './events.js';
|
||||
import EventTarget from './events/EventTarget.js';
|
||||
import EventType from './events/EventType.js';
|
||||
|
||||
@@ -44,10 +44,10 @@ inherits(Observable, EventTarget);
|
||||
Observable.unByKey = function(key) {
|
||||
if (Array.isArray(key)) {
|
||||
for (let i = 0, ii = key.length; i < ii; ++i) {
|
||||
_ol_events_.unlistenByKey(key[i]);
|
||||
unlistenByKey(key[i]);
|
||||
}
|
||||
} else {
|
||||
_ol_events_.unlistenByKey(/** @type {ol.EventsKey} */ (key));
|
||||
unlistenByKey(/** @type {ol.EventsKey} */ (key));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -101,11 +101,11 @@ Observable.prototype.on = function(type, listener) {
|
||||
const len = type.length;
|
||||
const keys = new Array(len);
|
||||
for (let i = 0; i < len; ++i) {
|
||||
keys[i] = _ol_events_.listen(this, type[i], listener);
|
||||
keys[i] = listen(this, type[i], listener);
|
||||
}
|
||||
return keys;
|
||||
} else {
|
||||
return _ol_events_.listen(
|
||||
return listen(
|
||||
this, /** @type {string} */ (type), listener);
|
||||
}
|
||||
};
|
||||
@@ -125,11 +125,11 @@ Observable.prototype.once = function(type, listener) {
|
||||
const len = type.length;
|
||||
const keys = new Array(len);
|
||||
for (let i = 0; i < len; ++i) {
|
||||
keys[i] = _ol_events_.listenOnce(this, type[i], listener);
|
||||
keys[i] = listenOnce(this, type[i], listener);
|
||||
}
|
||||
return keys;
|
||||
} else {
|
||||
return _ol_events_.listenOnce(
|
||||
return listenOnce(
|
||||
this, /** @type {string} */ (type), listener);
|
||||
}
|
||||
};
|
||||
@@ -144,11 +144,11 @@ Observable.prototype.once = function(type, listener) {
|
||||
Observable.prototype.un = function(type, listener) {
|
||||
if (Array.isArray(type)) {
|
||||
for (let i = 0, ii = type.length; i < ii; ++i) {
|
||||
_ol_events_.unlisten(this, type[i], listener);
|
||||
unlisten(this, type[i], listener);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
_ol_events_.unlisten(this, /** @type {string} */ (type), listener);
|
||||
unlisten(this, /** @type {string} */ (type), listener);
|
||||
}
|
||||
};
|
||||
export default Observable;
|
||||
|
||||
@@ -7,7 +7,7 @@ import BaseObject from './Object.js';
|
||||
import OverlayPositioning from './OverlayPositioning.js';
|
||||
import {CLASS_SELECTABLE} from './css.js';
|
||||
import {removeNode, removeChildren, outerWidth, outerHeight} from './dom.js';
|
||||
import _ol_events_ from './events.js';
|
||||
import {listen, unlistenByKey} from './events.js';
|
||||
import {containsExtent} from './extent.js';
|
||||
|
||||
|
||||
@@ -125,23 +125,23 @@ const Overlay = function(options) {
|
||||
*/
|
||||
this.mapPostrenderListenerKey = null;
|
||||
|
||||
_ol_events_.listen(
|
||||
listen(
|
||||
this, BaseObject.getChangeEventType(Property.ELEMENT),
|
||||
this.handleElementChanged, this);
|
||||
|
||||
_ol_events_.listen(
|
||||
listen(
|
||||
this, BaseObject.getChangeEventType(Property.MAP),
|
||||
this.handleMapChanged, this);
|
||||
|
||||
_ol_events_.listen(
|
||||
listen(
|
||||
this, BaseObject.getChangeEventType(Property.OFFSET),
|
||||
this.handleOffsetChanged, this);
|
||||
|
||||
_ol_events_.listen(
|
||||
listen(
|
||||
this, BaseObject.getChangeEventType(Property.POSITION),
|
||||
this.handlePositionChanged, this);
|
||||
|
||||
_ol_events_.listen(
|
||||
listen(
|
||||
this, BaseObject.getChangeEventType(Property.POSITIONING),
|
||||
this.handlePositioningChanged, this);
|
||||
|
||||
@@ -249,12 +249,12 @@ Overlay.prototype.handleElementChanged = function() {
|
||||
Overlay.prototype.handleMapChanged = function() {
|
||||
if (this.mapPostrenderListenerKey) {
|
||||
removeNode(this.element);
|
||||
_ol_events_.unlistenByKey(this.mapPostrenderListenerKey);
|
||||
unlistenByKey(this.mapPostrenderListenerKey);
|
||||
this.mapPostrenderListenerKey = null;
|
||||
}
|
||||
const map = this.getMap();
|
||||
if (map) {
|
||||
this.mapPostrenderListenerKey = _ol_events_.listen(map,
|
||||
this.mapPostrenderListenerKey = listen(map,
|
||||
MapEventType.POSTRENDER, this.render, this);
|
||||
this.updatePixelPosition();
|
||||
const container = this.stopEvent ?
|
||||
|
||||
@@ -17,7 +17,7 @@ import View from './View.js';
|
||||
import ViewHint from './ViewHint.js';
|
||||
import {assert} from './asserts.js';
|
||||
import {removeNode} from './dom.js';
|
||||
import _ol_events_ from './events.js';
|
||||
import {listen, unlistenByKey, unlisten} from './events.js';
|
||||
import Event from './events/Event.js';
|
||||
import EventType from './events/EventType.js';
|
||||
import {createEmpty, clone, createOrUpdateEmpty, equals, getForViewAndSize, isEmpty} from './extent.js';
|
||||
@@ -240,7 +240,7 @@ const PluggableMap = function(options) {
|
||||
EventType.WHEEL
|
||||
];
|
||||
for (let i = 0, ii = overlayEvents.length; i < ii; ++i) {
|
||||
_ol_events_.listen(this.overlayContainerStopEvent_, overlayEvents[i],
|
||||
listen(this.overlayContainerStopEvent_, overlayEvents[i],
|
||||
Event.stopPropagation);
|
||||
}
|
||||
this.viewport_.appendChild(this.overlayContainerStopEvent_);
|
||||
@@ -251,7 +251,7 @@ const PluggableMap = function(options) {
|
||||
*/
|
||||
this.mapBrowserEventHandler_ = new MapBrowserEventHandler(this, options.moveTolerance);
|
||||
for (const key in MapBrowserEventType) {
|
||||
_ol_events_.listen(this.mapBrowserEventHandler_, MapBrowserEventType[key],
|
||||
listen(this.mapBrowserEventHandler_, MapBrowserEventType[key],
|
||||
this.handleMapBrowserEvent, this);
|
||||
}
|
||||
|
||||
@@ -267,11 +267,11 @@ const PluggableMap = function(options) {
|
||||
*/
|
||||
this.keyHandlerKeys_ = null;
|
||||
|
||||
_ol_events_.listen(this.viewport_, EventType.CONTEXTMENU,
|
||||
listen(this.viewport_, EventType.CONTEXTMENU,
|
||||
this.handleBrowserEvent, this);
|
||||
_ol_events_.listen(this.viewport_, EventType.WHEEL,
|
||||
listen(this.viewport_, EventType.WHEEL,
|
||||
this.handleBrowserEvent, this);
|
||||
_ol_events_.listen(this.viewport_, EventType.MOUSEWHEEL,
|
||||
listen(this.viewport_, EventType.MOUSEWHEEL,
|
||||
this.handleBrowserEvent, this);
|
||||
|
||||
/**
|
||||
@@ -338,14 +338,14 @@ const PluggableMap = function(options) {
|
||||
*/
|
||||
this.skippedFeatureUids_ = {};
|
||||
|
||||
_ol_events_.listen(
|
||||
listen(
|
||||
this, BaseObject.getChangeEventType(MapProperty.LAYERGROUP),
|
||||
this.handleLayerGroupChanged_, this);
|
||||
_ol_events_.listen(this, BaseObject.getChangeEventType(MapProperty.VIEW),
|
||||
listen(this, BaseObject.getChangeEventType(MapProperty.VIEW),
|
||||
this.handleViewChanged_, this);
|
||||
_ol_events_.listen(this, BaseObject.getChangeEventType(MapProperty.SIZE),
|
||||
listen(this, BaseObject.getChangeEventType(MapProperty.SIZE),
|
||||
this.handleSizeChanged_, this);
|
||||
_ol_events_.listen(this, BaseObject.getChangeEventType(MapProperty.TARGET),
|
||||
listen(this, BaseObject.getChangeEventType(MapProperty.TARGET),
|
||||
this.handleTargetChanged_, this);
|
||||
|
||||
// setProperties will trigger the rendering of the map if the map
|
||||
@@ -361,7 +361,7 @@ const PluggableMap = function(options) {
|
||||
control.setMap(this);
|
||||
}.bind(this));
|
||||
|
||||
_ol_events_.listen(this.controls, CollectionEventType.ADD,
|
||||
listen(this.controls, CollectionEventType.ADD,
|
||||
/**
|
||||
* @param {ol.Collection.Event} event Collection event.
|
||||
*/
|
||||
@@ -369,7 +369,7 @@ const PluggableMap = function(options) {
|
||||
event.element.setMap(this);
|
||||
}, this);
|
||||
|
||||
_ol_events_.listen(this.controls, CollectionEventType.REMOVE,
|
||||
listen(this.controls, CollectionEventType.REMOVE,
|
||||
/**
|
||||
* @param {ol.Collection.Event} event Collection event.
|
||||
*/
|
||||
@@ -386,7 +386,7 @@ const PluggableMap = function(options) {
|
||||
interaction.setMap(this);
|
||||
}.bind(this));
|
||||
|
||||
_ol_events_.listen(this.interactions, CollectionEventType.ADD,
|
||||
listen(this.interactions, CollectionEventType.ADD,
|
||||
/**
|
||||
* @param {ol.Collection.Event} event Collection event.
|
||||
*/
|
||||
@@ -394,7 +394,7 @@ const PluggableMap = function(options) {
|
||||
event.element.setMap(this);
|
||||
}, this);
|
||||
|
||||
_ol_events_.listen(this.interactions, CollectionEventType.REMOVE,
|
||||
listen(this.interactions, CollectionEventType.REMOVE,
|
||||
/**
|
||||
* @param {ol.Collection.Event} event Collection event.
|
||||
*/
|
||||
@@ -404,7 +404,7 @@ const PluggableMap = function(options) {
|
||||
|
||||
this.overlays_.forEach(this.addOverlayInternal_.bind(this));
|
||||
|
||||
_ol_events_.listen(this.overlays_, CollectionEventType.ADD,
|
||||
listen(this.overlays_, CollectionEventType.ADD,
|
||||
/**
|
||||
* @param {ol.Collection.Event} event Collection event.
|
||||
*/
|
||||
@@ -412,7 +412,7 @@ const PluggableMap = function(options) {
|
||||
this.addOverlayInternal_(/** @type {ol.Overlay} */ (event.element));
|
||||
}, this);
|
||||
|
||||
_ol_events_.listen(this.overlays_, CollectionEventType.REMOVE,
|
||||
listen(this.overlays_, CollectionEventType.REMOVE,
|
||||
/**
|
||||
* @param {ol.Collection.Event} event Collection event.
|
||||
*/
|
||||
@@ -493,11 +493,11 @@ PluggableMap.prototype.addOverlayInternal_ = function(overlay) {
|
||||
*/
|
||||
PluggableMap.prototype.disposeInternal = function() {
|
||||
this.mapBrowserEventHandler_.dispose();
|
||||
_ol_events_.unlisten(this.viewport_, EventType.CONTEXTMENU,
|
||||
unlisten(this.viewport_, EventType.CONTEXTMENU,
|
||||
this.handleBrowserEvent, this);
|
||||
_ol_events_.unlisten(this.viewport_, EventType.WHEEL,
|
||||
unlisten(this.viewport_, EventType.WHEEL,
|
||||
this.handleBrowserEvent, this);
|
||||
_ol_events_.unlisten(this.viewport_, EventType.MOUSEWHEEL,
|
||||
unlisten(this.viewport_, EventType.MOUSEWHEEL,
|
||||
this.handleBrowserEvent, this);
|
||||
if (this.handleResize_ !== undefined) {
|
||||
window.removeEventListener(EventType.RESIZE,
|
||||
@@ -1004,7 +1004,7 @@ PluggableMap.prototype.handleTargetChanged_ = function() {
|
||||
|
||||
if (this.keyHandlerKeys_) {
|
||||
for (let i = 0, ii = this.keyHandlerKeys_.length; i < ii; ++i) {
|
||||
_ol_events_.unlistenByKey(this.keyHandlerKeys_[i]);
|
||||
unlistenByKey(this.keyHandlerKeys_[i]);
|
||||
}
|
||||
this.keyHandlerKeys_ = null;
|
||||
}
|
||||
@@ -1023,9 +1023,9 @@ PluggableMap.prototype.handleTargetChanged_ = function() {
|
||||
const keyboardEventTarget = !this.keyboardEventTarget_ ?
|
||||
targetElement : this.keyboardEventTarget_;
|
||||
this.keyHandlerKeys_ = [
|
||||
_ol_events_.listen(keyboardEventTarget, EventType.KEYDOWN,
|
||||
listen(keyboardEventTarget, EventType.KEYDOWN,
|
||||
this.handleBrowserEvent, this),
|
||||
_ol_events_.listen(keyboardEventTarget, EventType.KEYPRESS,
|
||||
listen(keyboardEventTarget, EventType.KEYPRESS,
|
||||
this.handleBrowserEvent, this)
|
||||
];
|
||||
|
||||
@@ -1063,20 +1063,20 @@ PluggableMap.prototype.handleViewPropertyChanged_ = function() {
|
||||
*/
|
||||
PluggableMap.prototype.handleViewChanged_ = function() {
|
||||
if (this.viewPropertyListenerKey_) {
|
||||
_ol_events_.unlistenByKey(this.viewPropertyListenerKey_);
|
||||
unlistenByKey(this.viewPropertyListenerKey_);
|
||||
this.viewPropertyListenerKey_ = null;
|
||||
}
|
||||
if (this.viewChangeListenerKey_) {
|
||||
_ol_events_.unlistenByKey(this.viewChangeListenerKey_);
|
||||
unlistenByKey(this.viewChangeListenerKey_);
|
||||
this.viewChangeListenerKey_ = null;
|
||||
}
|
||||
const view = this.getView();
|
||||
if (view) {
|
||||
this.viewport_.setAttribute('data-view', getUid(view));
|
||||
this.viewPropertyListenerKey_ = _ol_events_.listen(
|
||||
this.viewPropertyListenerKey_ = listen(
|
||||
view, ObjectEventType.PROPERTYCHANGE,
|
||||
this.handleViewPropertyChanged_, this);
|
||||
this.viewChangeListenerKey_ = _ol_events_.listen(
|
||||
this.viewChangeListenerKey_ = listen(
|
||||
view, EventType.CHANGE,
|
||||
this.handleViewPropertyChanged_, this);
|
||||
}
|
||||
@@ -1089,16 +1089,16 @@ PluggableMap.prototype.handleViewChanged_ = function() {
|
||||
*/
|
||||
PluggableMap.prototype.handleLayerGroupChanged_ = function() {
|
||||
if (this.layerGroupPropertyListenerKeys_) {
|
||||
this.layerGroupPropertyListenerKeys_.forEach(_ol_events_.unlistenByKey);
|
||||
this.layerGroupPropertyListenerKeys_.forEach(unlistenByKey);
|
||||
this.layerGroupPropertyListenerKeys_ = null;
|
||||
}
|
||||
const layerGroup = this.getLayerGroup();
|
||||
if (layerGroup) {
|
||||
this.layerGroupPropertyListenerKeys_ = [
|
||||
_ol_events_.listen(
|
||||
listen(
|
||||
layerGroup, ObjectEventType.PROPERTYCHANGE,
|
||||
this.render, this),
|
||||
_ol_events_.listen(
|
||||
listen(
|
||||
layerGroup, EventType.CHANGE,
|
||||
this.render, this)
|
||||
];
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {inherits} from './index.js';
|
||||
import TileState from './TileState.js';
|
||||
import _ol_events_ from './events.js';
|
||||
import {listen, unlisten} from './events.js';
|
||||
import EventType from './events/EventType.js';
|
||||
import PriorityQueue from './structs/PriorityQueue.js';
|
||||
|
||||
@@ -65,7 +65,7 @@ TileQueue.prototype.enqueue = function(element) {
|
||||
const added = PriorityQueue.prototype.enqueue.call(this, element);
|
||||
if (added) {
|
||||
const tile = element[0];
|
||||
_ol_events_.listen(tile, EventType.CHANGE,
|
||||
listen(tile, EventType.CHANGE,
|
||||
this.handleTileChange, this);
|
||||
}
|
||||
return added;
|
||||
@@ -89,7 +89,7 @@ TileQueue.prototype.handleTileChange = function(event) {
|
||||
const state = tile.getState();
|
||||
if (state === TileState.LOADED || state === TileState.ERROR ||
|
||||
state === TileState.EMPTY || state === TileState.ABORT) {
|
||||
_ol_events_.unlisten(tile, EventType.CHANGE,
|
||||
unlisten(tile, EventType.CHANGE,
|
||||
this.handleTileChange, this);
|
||||
const tileKey = tile.getKey();
|
||||
if (tileKey in this.tilesLoadingKeys_) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import {getUid, inherits} from './index.js';
|
||||
import Tile from './Tile.js';
|
||||
import TileState from './TileState.js';
|
||||
import {createCanvasContext2D} from './dom.js';
|
||||
import _ol_events_ from './events.js';
|
||||
import {listen, unlistenByKey} from './events.js';
|
||||
import {getHeight, getIntersection, getWidth} from './extent.js';
|
||||
import EventType from './events/EventType.js';
|
||||
import {loadFeaturesXhr} from './featureloader.js';
|
||||
@@ -111,7 +111,7 @@ const VectorImageTile = function(tileCoord, state, sourceRevision, format,
|
||||
tileUrl == undefined ? '' : tileUrl,
|
||||
format, tileLoadFunction);
|
||||
this.sourceTileListenerKeys_.push(
|
||||
_ol_events_.listen(sourceTile, EventType.CHANGE, handleTileChange));
|
||||
listen(sourceTile, EventType.CHANGE, handleTileChange));
|
||||
}
|
||||
sourceTile.consumers++;
|
||||
this.tileKeys.push(sourceTileKey);
|
||||
@@ -145,9 +145,9 @@ VectorImageTile.prototype.disposeInternal = function() {
|
||||
}
|
||||
this.tileKeys.length = 0;
|
||||
this.sourceTiles_ = null;
|
||||
this.loadListenerKeys_.forEach(_ol_events_.unlistenByKey);
|
||||
this.loadListenerKeys_.forEach(unlistenByKey);
|
||||
this.loadListenerKeys_.length = 0;
|
||||
this.sourceTileListenerKeys_.forEach(_ol_events_.unlistenByKey);
|
||||
this.sourceTileListenerKeys_.forEach(unlistenByKey);
|
||||
this.sourceTileListenerKeys_.length = 0;
|
||||
Tile.prototype.disposeInternal.call(this);
|
||||
};
|
||||
@@ -234,7 +234,7 @@ VectorImageTile.prototype.load = function() {
|
||||
sourceTile.load();
|
||||
}
|
||||
if (sourceTile.state == TileState.LOADING) {
|
||||
const key = _ol_events_.listen(sourceTile, EventType.CHANGE, function(e) {
|
||||
const key = listen(sourceTile, EventType.CHANGE, function(e) {
|
||||
const state = sourceTile.getState();
|
||||
if (state == TileState.LOADED ||
|
||||
state == TileState.ERROR) {
|
||||
@@ -277,7 +277,7 @@ VectorImageTile.prototype.finishLoading_ = function() {
|
||||
}
|
||||
}
|
||||
if (loaded == this.tileKeys.length) {
|
||||
this.loadListenerKeys_.forEach(_ol_events_.unlistenByKey);
|
||||
this.loadListenerKeys_.forEach(unlistenByKey);
|
||||
this.loadListenerKeys_.length = 0;
|
||||
this.setState(TileState.LOADED);
|
||||
} else {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {equals} from '../array.js';
|
||||
import Control from '../control/Control.js';
|
||||
import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js';
|
||||
import {removeChildren, replaceNode} from '../dom.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import Layer from '../layer/Layer.js';
|
||||
|
||||
@@ -87,7 +87,7 @@ const Attribution = function(opt_options) {
|
||||
button.title = tipLabel;
|
||||
button.appendChild(activeLabel);
|
||||
|
||||
_ol_events_.listen(button, EventType.CLICK, this.handleClick_, this);
|
||||
listen(button, EventType.CLICK, this.handleClick_, this);
|
||||
|
||||
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL +
|
||||
(this.collapsed_ && this.collapsible_ ? ' ol-collapsed' : '') +
|
||||
|
||||
@@ -5,7 +5,7 @@ import {inherits, nullFunction} from '../index.js';
|
||||
import MapEventType from '../MapEventType.js';
|
||||
import BaseObject from '../Object.js';
|
||||
import {removeNode} from '../dom.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen, unlistenByKey} from '../events.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -110,7 +110,7 @@ Control.prototype.setMap = function(map) {
|
||||
removeNode(this.element);
|
||||
}
|
||||
for (let i = 0, ii = this.listenerKeys.length; i < ii; ++i) {
|
||||
_ol_events_.unlistenByKey(this.listenerKeys[i]);
|
||||
unlistenByKey(this.listenerKeys[i]);
|
||||
}
|
||||
this.listenerKeys.length = 0;
|
||||
this.map_ = map;
|
||||
@@ -119,7 +119,7 @@ Control.prototype.setMap = function(map) {
|
||||
this.target_ : map.getOverlayContainerStopEvent();
|
||||
target.appendChild(this.element);
|
||||
if (this.render !== nullFunction) {
|
||||
this.listenerKeys.push(_ol_events_.listen(map,
|
||||
this.listenerKeys.push(listen(map,
|
||||
MapEventType.POSTRENDER, this.render, this));
|
||||
}
|
||||
map.render();
|
||||
|
||||
@@ -5,7 +5,7 @@ import {inherits} from '../index.js';
|
||||
import Control from '../control/Control.js';
|
||||
import {CLASS_CONTROL, CLASS_UNSELECTABLE, CLASS_UNSUPPORTED} from '../css.js';
|
||||
import {replaceNode} from '../dom.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ const FullScreen = function(opt_options) {
|
||||
button.title = tipLabel;
|
||||
button.appendChild(this.labelNode_);
|
||||
|
||||
_ol_events_.listen(button, EventType.CLICK,
|
||||
listen(button, EventType.CLICK,
|
||||
this.handleClick_, this);
|
||||
|
||||
const cssClasses = this.cssClassName_ + ' ' + CLASS_UNSELECTABLE +
|
||||
@@ -161,7 +161,7 @@ FullScreen.prototype.handleFullScreenChange_ = function() {
|
||||
FullScreen.prototype.setMap = function(map) {
|
||||
Control.prototype.setMap.call(this, map);
|
||||
if (map) {
|
||||
this.listenerKeys.push(_ol_events_.listen(document,
|
||||
this.listenerKeys.push(listen(document,
|
||||
FullScreen.getChangeType_(),
|
||||
this.handleFullScreenChange_, this)
|
||||
);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import BaseObject from '../Object.js';
|
||||
import Control from '../control/Control.js';
|
||||
@@ -38,7 +38,7 @@ const MousePosition = function(opt_options) {
|
||||
target: options.target
|
||||
});
|
||||
|
||||
_ol_events_.listen(this,
|
||||
listen(this,
|
||||
BaseObject.getChangeEventType(MousePosition.Property_.PROJECTION),
|
||||
this.handleProjectionChanged_, this);
|
||||
|
||||
@@ -171,9 +171,9 @@ MousePosition.prototype.setMap = function(map) {
|
||||
if (map) {
|
||||
const viewport = map.getViewport();
|
||||
this.listenerKeys.push(
|
||||
_ol_events_.listen(viewport, EventType.MOUSEMOVE,
|
||||
listen(viewport, EventType.MOUSEMOVE,
|
||||
this.handleMouseMove, this),
|
||||
_ol_events_.listen(viewport, EventType.MOUSEOUT,
|
||||
listen(viewport, EventType.MOUSEOUT,
|
||||
this.handleMouseOut, this)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import Control from '../control/Control.js';
|
||||
import _ol_coordinate_ from '../coordinate.js';
|
||||
import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js';
|
||||
import {replaceNode} from '../dom.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen, listenOnce, unlisten} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {containsExtent, getBottomLeft, getBottomRight, getTopLeft, getTopRight, scaleFromCenter} from '../extent.js';
|
||||
|
||||
@@ -101,7 +101,7 @@ const OverviewMap = function(opt_options) {
|
||||
button.title = tipLabel;
|
||||
button.appendChild(activeLabel);
|
||||
|
||||
_ol_events_.listen(button, EventType.CLICK,
|
||||
listen(button, EventType.CLICK,
|
||||
this.handleClick_, this);
|
||||
|
||||
/**
|
||||
@@ -225,7 +225,7 @@ OverviewMap.prototype.setMap = function(map) {
|
||||
|
||||
if (map) {
|
||||
this.ovmap_.setTarget(this.ovmapDiv_);
|
||||
this.listenerKeys.push(_ol_events_.listen(
|
||||
this.listenerKeys.push(listen(
|
||||
map, ObjectEventType.PROPERTYCHANGE,
|
||||
this.handleMapPropertyChange_, this));
|
||||
|
||||
@@ -269,7 +269,7 @@ OverviewMap.prototype.handleMapPropertyChange_ = function(event) {
|
||||
* @private
|
||||
*/
|
||||
OverviewMap.prototype.bindView_ = function(view) {
|
||||
_ol_events_.listen(view,
|
||||
listen(view,
|
||||
BaseObject.getChangeEventType(ViewProperty.ROTATION),
|
||||
this.handleRotationChanged_, this);
|
||||
};
|
||||
@@ -281,7 +281,7 @@ OverviewMap.prototype.bindView_ = function(view) {
|
||||
* @private
|
||||
*/
|
||||
OverviewMap.prototype.unbindView_ = function(view) {
|
||||
_ol_events_.unlisten(view,
|
||||
unlisten(view,
|
||||
BaseObject.getChangeEventType(ViewProperty.ROTATION),
|
||||
this.handleRotationChanged_, this);
|
||||
};
|
||||
@@ -503,7 +503,7 @@ OverviewMap.prototype.handleToggle_ = function() {
|
||||
if (!this.collapsed_ && !ovmap.isRendered()) {
|
||||
ovmap.updateSize();
|
||||
this.resetExtent_();
|
||||
_ol_events_.listenOnce(ovmap, MapEventType.POSTRENDER,
|
||||
listenOnce(ovmap, MapEventType.POSTRENDER,
|
||||
function(event) {
|
||||
this.updateBox_();
|
||||
},
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import Control from '../control/Control.js';
|
||||
import {CLASS_CONTROL, CLASS_HIDDEN, CLASS_UNSELECTABLE} from '../css.js';
|
||||
import {easeOut} from '../easing.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {inherits} from '../index.js';
|
||||
|
||||
@@ -51,7 +51,7 @@ const Rotate = function(opt_options) {
|
||||
button.title = tipLabel;
|
||||
button.appendChild(this.label_);
|
||||
|
||||
_ol_events_.listen(button, EventType.CLICK,
|
||||
listen(button, EventType.CLICK,
|
||||
Rotate.prototype.handleClick_, this);
|
||||
|
||||
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL;
|
||||
|
||||
@@ -7,7 +7,7 @@ import {assert} from '../asserts.js';
|
||||
import Control from '../control/Control.js';
|
||||
import ScaleLineUnits from '../control/ScaleLineUnits.js';
|
||||
import {CLASS_UNSELECTABLE} from '../css.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen} from '../events.js';
|
||||
import {getPointResolution, METERS_PER_UNIT} from '../proj.js';
|
||||
import Units from '../proj/Units.js';
|
||||
|
||||
@@ -85,7 +85,7 @@ const ScaleLine = function(opt_options) {
|
||||
target: options.target
|
||||
});
|
||||
|
||||
_ol_events_.listen(
|
||||
listen(
|
||||
this, BaseObject.getChangeEventType(ScaleLine.Property_.UNITS),
|
||||
this.handleUnitsChanged_, this);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/control/Zoom
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import Control from '../control/Control.js';
|
||||
import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js';
|
||||
@@ -43,7 +43,7 @@ const Zoom = function(opt_options) {
|
||||
typeof zoomInLabel === 'string' ? document.createTextNode(zoomInLabel) : zoomInLabel
|
||||
);
|
||||
|
||||
_ol_events_.listen(inElement, EventType.CLICK,
|
||||
listen(inElement, EventType.CLICK,
|
||||
Zoom.prototype.handleClick_.bind(this, delta));
|
||||
|
||||
const outElement = document.createElement('button');
|
||||
@@ -54,7 +54,7 @@ const Zoom = function(opt_options) {
|
||||
typeof zoomOutLabel === 'string' ? document.createTextNode(zoomOutLabel) : zoomOutLabel
|
||||
);
|
||||
|
||||
_ol_events_.listen(outElement, EventType.CLICK,
|
||||
listen(outElement, EventType.CLICK,
|
||||
Zoom.prototype.handleClick_.bind(this, -delta));
|
||||
|
||||
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL;
|
||||
|
||||
@@ -8,7 +8,7 @@ import ViewHint from '../ViewHint.js';
|
||||
import Control from '../control/Control.js';
|
||||
import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js';
|
||||
import {easeOut} from '../easing.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen} from '../events.js';
|
||||
import Event from '../events/Event.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {clamp} from '../math.js';
|
||||
@@ -113,16 +113,16 @@ const ZoomSlider = function(opt_options) {
|
||||
*/
|
||||
this.dragger_ = new PointerEventHandler(containerElement);
|
||||
|
||||
_ol_events_.listen(this.dragger_, PointerEventType.POINTERDOWN,
|
||||
listen(this.dragger_, PointerEventType.POINTERDOWN,
|
||||
this.handleDraggerStart_, this);
|
||||
_ol_events_.listen(this.dragger_, PointerEventType.POINTERMOVE,
|
||||
listen(this.dragger_, PointerEventType.POINTERMOVE,
|
||||
this.handleDraggerDrag_, this);
|
||||
_ol_events_.listen(this.dragger_, PointerEventType.POINTERUP,
|
||||
listen(this.dragger_, PointerEventType.POINTERUP,
|
||||
this.handleDraggerEnd_, this);
|
||||
|
||||
_ol_events_.listen(containerElement, EventType.CLICK,
|
||||
listen(containerElement, EventType.CLICK,
|
||||
this.handleContainerClick_, this);
|
||||
_ol_events_.listen(thumbElement, EventType.CLICK,
|
||||
listen(thumbElement, EventType.CLICK,
|
||||
Event.stopPropagation);
|
||||
|
||||
const render = options.render ? options.render : ZoomSlider.render;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/control/ZoomToExtent
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import Control from '../control/Control.js';
|
||||
import {CLASS_CONTROL, CLASS_UNSELECTABLE} from '../css.js';
|
||||
@@ -39,7 +39,7 @@ const ZoomToExtent = function(opt_options) {
|
||||
typeof label === 'string' ? document.createTextNode(label) : label
|
||||
);
|
||||
|
||||
_ol_events_.listen(button, EventType.CLICK,
|
||||
listen(button, EventType.CLICK,
|
||||
this.handleClick_, this);
|
||||
|
||||
const cssClasses = className + ' ' + CLASS_UNSELECTABLE + ' ' + CLASS_CONTROL;
|
||||
|
||||
@@ -2,25 +2,24 @@
|
||||
* @module ol/events
|
||||
*/
|
||||
import {clear} from './obj.js';
|
||||
const _ol_events_ = {};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.EventsKey} listenerObj Listener object.
|
||||
* @return {ol.EventsListenerFunctionType} Bound listener.
|
||||
*/
|
||||
_ol_events_.bindListener_ = function(listenerObj) {
|
||||
export function bindListener(listenerObj) {
|
||||
const boundListener = function(evt) {
|
||||
const listener = listenerObj.listener;
|
||||
const bindTo = listenerObj.bindTo || listenerObj.target;
|
||||
if (listenerObj.callOnce) {
|
||||
_ol_events_.unlistenByKey(listenerObj);
|
||||
unlistenByKey(listenerObj);
|
||||
}
|
||||
return listener.call(bindTo, evt);
|
||||
};
|
||||
listenerObj.boundListener = boundListener;
|
||||
return boundListener;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -33,9 +32,8 @@ _ol_events_.bindListener_ = function(listenerObj) {
|
||||
* @param {boolean=} opt_setDeleteIndex Set the deleteIndex on the matching
|
||||
* listener, for {@link ol.events.unlistenByKey}.
|
||||
* @return {ol.EventsKey|undefined} The matching listener object.
|
||||
* @private
|
||||
*/
|
||||
_ol_events_.findListener_ = function(listeners, listener, opt_this,
|
||||
export function findListener(listeners, listener, opt_this,
|
||||
opt_setDeleteIndex) {
|
||||
let listenerObj;
|
||||
for (let i = 0, ii = listeners.length; i < ii; ++i) {
|
||||
@@ -49,7 +47,7 @@ _ol_events_.findListener_ = function(listeners, listener, opt_this,
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -57,10 +55,10 @@ _ol_events_.findListener_ = function(listeners, listener, opt_this,
|
||||
* @param {string} type Type.
|
||||
* @return {Array.<ol.EventsKey>|undefined} Listeners.
|
||||
*/
|
||||
_ol_events_.getListeners = function(target, type) {
|
||||
export function getListeners(target, type) {
|
||||
const listenerMap = target.ol_lm;
|
||||
return listenerMap ? listenerMap[type] : undefined;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -69,15 +67,14 @@ _ol_events_.getListeners = function(target, type) {
|
||||
* @param {ol.EventTargetLike} target Target.
|
||||
* @return {!Object.<string, Array.<ol.EventsKey>>} Map of
|
||||
* listeners by event type.
|
||||
* @private
|
||||
*/
|
||||
_ol_events_.getListenerMap_ = function(target) {
|
||||
function getListenerMap(target) {
|
||||
let listenerMap = target.ol_lm;
|
||||
if (!listenerMap) {
|
||||
listenerMap = target.ol_lm = {};
|
||||
}
|
||||
return listenerMap;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -86,10 +83,9 @@ _ol_events_.getListenerMap_ = function(target) {
|
||||
* map, it will be removed from the target.
|
||||
* @param {ol.EventTargetLike} target Target.
|
||||
* @param {string} type Type.
|
||||
* @private
|
||||
*/
|
||||
_ol_events_.removeListeners_ = function(target, type) {
|
||||
const listeners = _ol_events_.getListeners(target, type);
|
||||
function removeListeners(target, type) {
|
||||
const listeners = getListeners(target, type);
|
||||
if (listeners) {
|
||||
for (let i = 0, ii = listeners.length; i < ii; ++i) {
|
||||
target.removeEventListener(type, listeners[i].boundListener);
|
||||
@@ -104,7 +100,7 @@ _ol_events_.removeListeners_ = function(target, type) {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -122,13 +118,13 @@ _ol_events_.removeListeners_ = function(target, type) {
|
||||
* @param {boolean=} opt_once If true, add the listener as one-off listener.
|
||||
* @return {ol.EventsKey} Unique key for the listener.
|
||||
*/
|
||||
_ol_events_.listen = function(target, type, listener, opt_this, opt_once) {
|
||||
const listenerMap = _ol_events_.getListenerMap_(target);
|
||||
export function listen(target, type, listener, opt_this, opt_once) {
|
||||
const listenerMap = getListenerMap(target);
|
||||
let listeners = listenerMap[type];
|
||||
if (!listeners) {
|
||||
listeners = listenerMap[type] = [];
|
||||
}
|
||||
let listenerObj = _ol_events_.findListener_(listeners, listener, opt_this,
|
||||
let listenerObj = findListener(listeners, listener, opt_this,
|
||||
false);
|
||||
if (listenerObj) {
|
||||
if (!opt_once) {
|
||||
@@ -143,12 +139,12 @@ _ol_events_.listen = function(target, type, listener, opt_this, opt_once) {
|
||||
target: target,
|
||||
type: type
|
||||
});
|
||||
target.addEventListener(type, _ol_events_.bindListener_(listenerObj));
|
||||
target.addEventListener(type, bindListener(listenerObj));
|
||||
listeners.push(listenerObj);
|
||||
}
|
||||
|
||||
return listenerObj;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -171,9 +167,9 @@ _ol_events_.listen = function(target, type, listener, opt_this, opt_once) {
|
||||
* listener. Default is the `target`.
|
||||
* @return {ol.EventsKey} Key for unlistenByKey.
|
||||
*/
|
||||
_ol_events_.listenOnce = function(target, type, listener, opt_this) {
|
||||
return _ol_events_.listen(target, type, listener, opt_this, true);
|
||||
};
|
||||
export function listenOnce(target, type, listener, opt_this) {
|
||||
return listen(target, type, listener, opt_this, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -189,16 +185,16 @@ _ol_events_.listenOnce = function(target, type, listener, opt_this) {
|
||||
* @param {Object=} opt_this Object referenced by the `this` keyword in the
|
||||
* listener. Default is the `target`.
|
||||
*/
|
||||
_ol_events_.unlisten = function(target, type, listener, opt_this) {
|
||||
const listeners = _ol_events_.getListeners(target, type);
|
||||
export function unlisten(target, type, listener, opt_this) {
|
||||
const listeners = getListeners(target, type);
|
||||
if (listeners) {
|
||||
const listenerObj = _ol_events_.findListener_(listeners, listener, opt_this,
|
||||
const listenerObj = findListener(listeners, listener, opt_this,
|
||||
true);
|
||||
if (listenerObj) {
|
||||
_ol_events_.unlistenByKey(listenerObj);
|
||||
unlistenByKey(listenerObj);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -210,22 +206,22 @@ _ol_events_.unlisten = function(target, type, listener, opt_this) {
|
||||
*
|
||||
* @param {ol.EventsKey} key The key.
|
||||
*/
|
||||
_ol_events_.unlistenByKey = function(key) {
|
||||
export function unlistenByKey(key) {
|
||||
if (key && key.target) {
|
||||
key.target.removeEventListener(key.type, key.boundListener);
|
||||
const listeners = _ol_events_.getListeners(key.target, key.type);
|
||||
const listeners = getListeners(key.target, key.type);
|
||||
if (listeners) {
|
||||
const i = 'deleteIndex' in key ? key.deleteIndex : listeners.indexOf(key);
|
||||
if (i !== -1) {
|
||||
listeners.splice(i, 1);
|
||||
}
|
||||
if (listeners.length === 0) {
|
||||
_ol_events_.removeListeners_(key.target, key.type);
|
||||
removeListeners(key.target, key.type);
|
||||
}
|
||||
}
|
||||
clear(key);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -234,10 +230,9 @@ _ol_events_.unlistenByKey = function(key) {
|
||||
*
|
||||
* @param {ol.EventTargetLike} target Target.
|
||||
*/
|
||||
_ol_events_.unlistenAll = function(target) {
|
||||
const listenerMap = _ol_events_.getListenerMap_(target);
|
||||
export function unlistenAll(target) {
|
||||
const listenerMap = getListenerMap(target);
|
||||
for (const type in listenerMap) {
|
||||
_ol_events_.removeListeners_(target, type);
|
||||
removeListeners(target, type);
|
||||
}
|
||||
};
|
||||
export default _ol_events_;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {inherits, nullFunction} from '../index.js';
|
||||
import Disposable from '../Disposable.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {unlistenAll} from '../events.js';
|
||||
import Event from '../events/Event.js';
|
||||
|
||||
/**
|
||||
@@ -109,7 +109,7 @@ EventTarget.prototype.dispatchEvent = function(event) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
EventTarget.prototype.disposeInternal = function() {
|
||||
_ol_events_.unlistenAll(this);
|
||||
unlistenAll(this);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/geom/GeometryCollection
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen, unlisten} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {createOrUpdateEmpty, closestSquaredDistanceXY, extend, getCenter} from '../extent.js';
|
||||
import Geometry from '../geom/Geometry.js';
|
||||
@@ -56,7 +56,7 @@ GeometryCollection.prototype.unlistenGeometriesChange_ = function() {
|
||||
return;
|
||||
}
|
||||
for (let i = 0, ii = this.geometries_.length; i < ii; ++i) {
|
||||
_ol_events_.unlisten(
|
||||
unlisten(
|
||||
this.geometries_[i], EventType.CHANGE,
|
||||
this.changed, this);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ GeometryCollection.prototype.listenGeometriesChange_ = function() {
|
||||
return;
|
||||
}
|
||||
for (let i = 0, ii = this.geometries_.length; i < ii; ++i) {
|
||||
_ol_events_.listen(
|
||||
listen(
|
||||
this.geometries_[i], EventType.CHANGE,
|
||||
this.changed, this);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
};
|
||||
|
||||
@@ -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)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen, unlisten} from '../events.js';
|
||||
import EventTarget from '../events/EventTarget.js';
|
||||
import _ol_has_ from '../has.js';
|
||||
import PointerEventType from '../pointer/EventType.js';
|
||||
@@ -176,7 +176,7 @@ PointerEventHandler.prototype.eventHandler_ = function(inEvent) {
|
||||
*/
|
||||
PointerEventHandler.prototype.addEvents_ = function(events) {
|
||||
events.forEach(function(eventName) {
|
||||
_ol_events_.listen(this.element_, eventName, this.eventHandler_, this);
|
||||
listen(this.element_, eventName, this.eventHandler_, this);
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
@@ -188,7 +188,7 @@ PointerEventHandler.prototype.addEvents_ = function(events) {
|
||||
*/
|
||||
PointerEventHandler.prototype.removeEvents_ = function(events) {
|
||||
events.forEach(function(e) {
|
||||
_ol_events_.unlisten(this.element_, e, this.eventHandler_, this);
|
||||
unlisten(this.element_, e, this.eventHandler_, this);
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import {getUid, inherits, nullFunction} from '../index.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import Observable from '../Observable.js';
|
||||
import TileState from '../TileState.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {FALSE} from '../functions.js';
|
||||
import SourceState from '../source/State.js';
|
||||
@@ -115,7 +115,7 @@ LayerRenderer.prototype.handleImageChange_ = function(event) {
|
||||
LayerRenderer.prototype.loadImage = function(image) {
|
||||
let imageState = image.getState();
|
||||
if (imageState != ImageState.LOADED && imageState != ImageState.ERROR) {
|
||||
_ol_events_.listen(image, EventType.CHANGE, this.handleImageChange_, this);
|
||||
listen(image, EventType.CHANGE, this.handleImageChange_, this);
|
||||
}
|
||||
if (imageState == ImageState.IDLE) {
|
||||
image.load();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {getUid, inherits, nullFunction} from '../index.js';
|
||||
import Disposable from '../Disposable.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen, unlistenByKey} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {getWidth} from '../extent.js';
|
||||
import {TRUE} from '../functions.js';
|
||||
@@ -219,7 +219,7 @@ MapRenderer.prototype.getLayerRenderer = function(layer) {
|
||||
}
|
||||
if (renderer) {
|
||||
this.layerRenderers_[layerKey] = renderer;
|
||||
this.layerRendererListeners_[layerKey] = _ol_events_.listen(renderer,
|
||||
this.layerRendererListeners_[layerKey] = listen(renderer,
|
||||
EventType.CHANGE, this.handleLayerRendererChange_, this);
|
||||
} else {
|
||||
throw new Error('Unable to create renderer for layer: ' + layer.getType());
|
||||
@@ -281,7 +281,7 @@ MapRenderer.prototype.removeLayerRendererByKey_ = function(layerKey) {
|
||||
const layerRenderer = this.layerRenderers_[layerKey];
|
||||
delete this.layerRenderers_[layerKey];
|
||||
|
||||
_ol_events_.unlistenByKey(this.layerRendererListeners_[layerKey]);
|
||||
unlistenByKey(this.layerRendererListeners_[layerKey]);
|
||||
delete this.layerRendererListeners_[layerKey];
|
||||
|
||||
return layerRenderer;
|
||||
|
||||
@@ -5,7 +5,7 @@ import {getUid, inherits} from '../../index.js';
|
||||
import LayerType from '../../LayerType.js';
|
||||
import ViewHint from '../../ViewHint.js';
|
||||
import {createCanvasContext2D} from '../../dom.js';
|
||||
import _ol_events_ from '../../events.js';
|
||||
import {listen, unlisten} from '../../events.js';
|
||||
import EventType from '../../events/EventType.js';
|
||||
import rbush from 'rbush';
|
||||
import {buffer, createEmpty, containsExtent, getWidth} from '../../extent.js';
|
||||
@@ -79,7 +79,7 @@ const CanvasVectorLayerRenderer = function(vectorLayer) {
|
||||
*/
|
||||
this.context = createCanvasContext2D();
|
||||
|
||||
_ol_events_.listen(_ol_render_canvas_.labelCache, EventType.CLEAR, this.handleFontsChanged_, this);
|
||||
listen(_ol_render_canvas_.labelCache, EventType.CLEAR, this.handleFontsChanged_, this);
|
||||
|
||||
};
|
||||
|
||||
@@ -112,7 +112,7 @@ CanvasVectorLayerRenderer['create'] = function(mapRenderer, layer) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
CanvasVectorLayerRenderer.prototype.disposeInternal = function() {
|
||||
_ol_events_.unlisten(_ol_render_canvas_.labelCache, EventType.CLEAR, this.handleFontsChanged_, this);
|
||||
unlisten(_ol_render_canvas_.labelCache, EventType.CLEAR, this.handleFontsChanged_, this);
|
||||
CanvasLayerRenderer.prototype.disposeInternal.call(this);
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import {getUid, inherits} from '../../index.js';
|
||||
import LayerType from '../../LayerType.js';
|
||||
import TileState from '../../TileState.js';
|
||||
import {createCanvasContext2D} from '../../dom.js';
|
||||
import _ol_events_ from '../../events.js';
|
||||
import {listen, unlisten} from '../../events.js';
|
||||
import EventType from '../../events/EventType.js';
|
||||
import rbush from 'rbush';
|
||||
import {buffer, containsCoordinate, equals, getIntersection, getTopLeft, intersects} from '../../extent.js';
|
||||
@@ -64,7 +64,7 @@ const CanvasVectorTileLayerRenderer = function(layer) {
|
||||
this.zDirection =
|
||||
layer.getRenderMode() == _ol_layer_VectorTileRenderType_.VECTOR ? 1 : 0;
|
||||
|
||||
_ol_events_.listen(_ol_render_canvas_.labelCache, EventType.CLEAR, this.handleFontsChanged_, this);
|
||||
listen(_ol_render_canvas_.labelCache, EventType.CLEAR, this.handleFontsChanged_, this);
|
||||
|
||||
};
|
||||
|
||||
@@ -119,7 +119,7 @@ CanvasVectorTileLayerRenderer.VECTOR_REPLAYS = {
|
||||
* @inheritDoc
|
||||
*/
|
||||
CanvasVectorTileLayerRenderer.prototype.disposeInternal = function() {
|
||||
_ol_events_.unlisten(_ol_render_canvas_.labelCache, EventType.CLEAR, this.handleFontsChanged_, this);
|
||||
unlisten(_ol_render_canvas_.labelCache, EventType.CLEAR, this.handleFontsChanged_, this);
|
||||
CanvasTileLayerRenderer.prototype.disposeInternal.call(this);
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import {inherits} from '../../index.js';
|
||||
import {stableSort} from '../../array.js';
|
||||
import {CLASS_UNSELECTABLE} from '../../css.js';
|
||||
import {createCanvasContext2D} from '../../dom.js';
|
||||
import _ol_events_ from '../../events.js';
|
||||
import {listen} from '../../events.js';
|
||||
import _ol_has_ from '../../has.js';
|
||||
import Layer from '../../layer/Layer.js';
|
||||
import RenderEvent from '../../render/Event.js';
|
||||
@@ -92,9 +92,9 @@ const WebGLMapRenderer = function(container, map) {
|
||||
*/
|
||||
this.context_ = new _ol_webgl_Context_(this.canvas_, this.gl_);
|
||||
|
||||
_ol_events_.listen(this.canvas_, ContextEventType.LOST,
|
||||
listen(this.canvas_, ContextEventType.LOST,
|
||||
this.handleWebGLContextLost, this);
|
||||
_ol_events_.listen(this.canvas_, ContextEventType.RESTORED,
|
||||
listen(this.canvas_, ContextEventType.RESTORED,
|
||||
this.handleWebGLContextRestored, this);
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@ import {ERROR_THRESHOLD} from './common.js';
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_ImageBase_ from '../ImageBase.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen, unlistenByKey} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {getCenter, getIntersection, getHeight, getWidth} from '../extent.js';
|
||||
import _ol_reproj_ from '../reproj.js';
|
||||
@@ -172,7 +172,7 @@ ReprojImage.prototype.load = function() {
|
||||
if (sourceState == ImageState.LOADED || sourceState == ImageState.ERROR) {
|
||||
this.reproject_();
|
||||
} else {
|
||||
this.sourceListenerKey_ = _ol_events_.listen(this.sourceImage_,
|
||||
this.sourceListenerKey_ = listen(this.sourceImage_,
|
||||
EventType.CHANGE, function(e) {
|
||||
const sourceState = this.sourceImage_.getState();
|
||||
if (sourceState == ImageState.LOADED || sourceState == ImageState.ERROR) {
|
||||
@@ -190,7 +190,7 @@ ReprojImage.prototype.load = function() {
|
||||
* @private
|
||||
*/
|
||||
ReprojImage.prototype.unlistenSource_ = function() {
|
||||
_ol_events_.unlistenByKey(/** @type {!ol.EventsKey} */ (this.sourceListenerKey_));
|
||||
unlistenByKey(/** @type {!ol.EventsKey} */ (this.sourceListenerKey_));
|
||||
this.sourceListenerKey_ = null;
|
||||
};
|
||||
export default ReprojImage;
|
||||
|
||||
@@ -5,7 +5,7 @@ import {ERROR_THRESHOLD} from './common.js';
|
||||
import {inherits} from '../index.js';
|
||||
import Tile from '../Tile.js';
|
||||
import TileState from '../TileState.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen, unlistenByKey} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {getArea, getCenter, getIntersection} from '../extent.js';
|
||||
import {clamp} from '../math.js';
|
||||
@@ -264,13 +264,13 @@ ReprojTile.prototype.load = function() {
|
||||
if (state == TileState.IDLE || state == TileState.LOADING) {
|
||||
leftToLoad++;
|
||||
|
||||
const sourceListenKey = _ol_events_.listen(tile, EventType.CHANGE,
|
||||
const sourceListenKey = listen(tile, EventType.CHANGE,
|
||||
function(e) {
|
||||
const state = tile.getState();
|
||||
if (state == TileState.LOADED ||
|
||||
state == TileState.ERROR ||
|
||||
state == TileState.EMPTY) {
|
||||
_ol_events_.unlistenByKey(sourceListenKey);
|
||||
unlistenByKey(sourceListenKey);
|
||||
leftToLoad--;
|
||||
if (leftToLoad === 0) {
|
||||
this.unlistenSources_();
|
||||
@@ -300,7 +300,7 @@ ReprojTile.prototype.load = function() {
|
||||
* @private
|
||||
*/
|
||||
ReprojTile.prototype.unlistenSources_ = function() {
|
||||
this.sourcesListenerKeys_.forEach(_ol_events_.unlistenByKey);
|
||||
this.sourcesListenerKeys_.forEach(unlistenByKey);
|
||||
this.sourcesListenerKeys_ = null;
|
||||
};
|
||||
export default ReprojTile;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_Image_ from '../Image.js';
|
||||
import {assert} from '../asserts.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {containsExtent, getHeight, getWidth} from '../extent.js';
|
||||
import {assign} from '../obj.js';
|
||||
@@ -173,7 +173,7 @@ ImageArcGISRest.prototype.getImageInternal = function(extent, resolution, pixelR
|
||||
|
||||
this.renderedRevision_ = this.getRevision();
|
||||
|
||||
_ol_events_.listen(this.image_, EventType.CHANGE,
|
||||
listen(this.image_, EventType.CHANGE,
|
||||
this.handleImageChange, this);
|
||||
|
||||
return this.image_;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_Image_ from '../Image.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {containsExtent, getCenter, getHeight, getWidth, scaleFromCenter} from '../extent.js';
|
||||
import {assign} from '../obj.js';
|
||||
@@ -144,7 +144,7 @@ ImageMapGuide.prototype.getImageInternal = function(extent, resolution, pixelRat
|
||||
image = new _ol_Image_(extent, resolution, pixelRatio,
|
||||
imageUrl, this.crossOrigin_,
|
||||
this.imageLoadFunction_);
|
||||
_ol_events_.listen(image, EventType.CHANGE,
|
||||
listen(image, EventType.CHANGE,
|
||||
this.handleImageChange, this);
|
||||
} else {
|
||||
image = null;
|
||||
|
||||
@@ -5,7 +5,7 @@ import {inherits} from '../index.js';
|
||||
import _ol_Image_ from '../Image.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import {createCanvasContext2D} from '../dom.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {intersects, getHeight, getWidth} from '../extent.js';
|
||||
import {get as getProjection} from '../proj.js';
|
||||
@@ -47,7 +47,7 @@ const Static = function(options) {
|
||||
*/
|
||||
this.imageSize_ = options.imageSize ? options.imageSize : null;
|
||||
|
||||
_ol_events_.listen(this.image_, EventType.CHANGE,
|
||||
listen(this.image_, EventType.CHANGE,
|
||||
this.handleImageChange, this);
|
||||
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ import {DEFAULT_WMS_VERSION} from './common.js';
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_Image_ from '../Image.js';
|
||||
import {assert} from '../asserts.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {containsExtent, getCenter, getForViewAndSize, getHeight, getWidth} from '../extent.js';
|
||||
import {assign} from '../obj.js';
|
||||
@@ -236,7 +236,7 @@ ImageWMS.prototype.getImageInternal = function(extent, resolution, pixelRatio, p
|
||||
|
||||
this.renderedRevision_ = this.getRevision();
|
||||
|
||||
_ol_events_.listen(this.image_, EventType.CHANGE,
|
||||
listen(this.image_, EventType.CHANGE,
|
||||
this.handleImageChange, this);
|
||||
|
||||
return this.image_;
|
||||
|
||||
@@ -5,7 +5,7 @@ import {getUid, inherits} from '../index.js';
|
||||
import ImageCanvas from '../ImageCanvas.js';
|
||||
import TileQueue from '../TileQueue.js';
|
||||
import {createCanvasContext2D} from '../dom.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen} from '../events.js';
|
||||
import Event from '../events/Event.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {Processor} from 'pixelworks';
|
||||
@@ -82,7 +82,7 @@ const RasterSource = function(options) {
|
||||
this.renderers_ = createRenderers(options.sources);
|
||||
|
||||
for (let r = 0, rr = this.renderers_.length; r < rr; ++r) {
|
||||
_ol_events_.listen(this.renderers_[r], EventType.CHANGE,
|
||||
listen(this.renderers_[r], EventType.CHANGE,
|
||||
this.changed, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import {getUid, inherits} from '../index.js';
|
||||
import ImageTile from '../ImageTile.js';
|
||||
import TileCache from '../TileCache.js';
|
||||
import TileState from '../TileState.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {equivalent, get as getProjection} from '../proj.js';
|
||||
import ReprojTile from '../reproj/Tile.js';
|
||||
@@ -224,7 +224,7 @@ TileImage.prototype.createTile_ = function(z, x, y, pixelRatio, projection, key)
|
||||
this.tileLoadFunction,
|
||||
this.tileOptions);
|
||||
tile.key = key;
|
||||
_ol_events_.listen(tile, EventType.CHANGE,
|
||||
listen(tile, EventType.CHANGE,
|
||||
this.handleTileChange, this);
|
||||
return tile;
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ import Tile from '../Tile.js';
|
||||
import TileState from '../TileState.js';
|
||||
import {createFromTemplates, nullTileUrlFunction} from '../tileurlfunction.js';
|
||||
import {assert} from '../asserts.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listenOnce} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {applyTransform, intersects} from '../extent.js';
|
||||
import _ol_net_ from '../net.js';
|
||||
@@ -371,7 +371,7 @@ UTFGrid.Tile_.prototype.getData = function(coordinate) {
|
||||
*/
|
||||
UTFGrid.Tile_.prototype.forDataAtCoordinate = function(coordinate, callback, opt_this, opt_request) {
|
||||
if (this.state == TileState.IDLE && opt_request === true) {
|
||||
_ol_events_.listenOnce(this, EventType.CHANGE, function(e) {
|
||||
listenOnce(this, EventType.CHANGE, function(e) {
|
||||
callback.call(opt_this, this.getData(coordinate));
|
||||
}, this);
|
||||
this.loadInternal_();
|
||||
|
||||
@@ -8,7 +8,7 @@ import CollectionEventType from '../CollectionEventType.js';
|
||||
import ObjectEventType from '../ObjectEventType.js';
|
||||
import {extend} from '../array.js';
|
||||
import {assert} from '../asserts.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 {containsExtent, equals} from '../extent.js';
|
||||
@@ -203,9 +203,9 @@ VectorSource.prototype.addFeatureInternal = function(feature) {
|
||||
*/
|
||||
VectorSource.prototype.setupChangeEvents_ = function(featureKey, feature) {
|
||||
this.featureChangeKeys_[featureKey] = [
|
||||
_ol_events_.listen(feature, EventType.CHANGE,
|
||||
listen(feature, EventType.CHANGE,
|
||||
this.handleFeatureChange_, this),
|
||||
_ol_events_.listen(feature, ObjectEventType.PROPERTYCHANGE,
|
||||
listen(feature, ObjectEventType.PROPERTYCHANGE,
|
||||
this.handleFeatureChange_, this)
|
||||
];
|
||||
};
|
||||
@@ -295,7 +295,7 @@ VectorSource.prototype.addFeaturesInternal = function(features) {
|
||||
*/
|
||||
VectorSource.prototype.bindFeaturesCollection_ = function(collection) {
|
||||
let modifyingCollection = false;
|
||||
_ol_events_.listen(this, VectorEventType.ADDFEATURE,
|
||||
listen(this, VectorEventType.ADDFEATURE,
|
||||
function(evt) {
|
||||
if (!modifyingCollection) {
|
||||
modifyingCollection = true;
|
||||
@@ -303,7 +303,7 @@ VectorSource.prototype.bindFeaturesCollection_ = function(collection) {
|
||||
modifyingCollection = false;
|
||||
}
|
||||
});
|
||||
_ol_events_.listen(this, VectorEventType.REMOVEFEATURE,
|
||||
listen(this, VectorEventType.REMOVEFEATURE,
|
||||
function(evt) {
|
||||
if (!modifyingCollection) {
|
||||
modifyingCollection = true;
|
||||
@@ -311,7 +311,7 @@ VectorSource.prototype.bindFeaturesCollection_ = function(collection) {
|
||||
modifyingCollection = false;
|
||||
}
|
||||
});
|
||||
_ol_events_.listen(collection, CollectionEventType.ADD,
|
||||
listen(collection, CollectionEventType.ADD,
|
||||
function(evt) {
|
||||
if (!modifyingCollection) {
|
||||
modifyingCollection = true;
|
||||
@@ -319,7 +319,7 @@ VectorSource.prototype.bindFeaturesCollection_ = function(collection) {
|
||||
modifyingCollection = false;
|
||||
}
|
||||
}, this);
|
||||
_ol_events_.listen(collection, CollectionEventType.REMOVE,
|
||||
listen(collection, CollectionEventType.REMOVE,
|
||||
function(evt) {
|
||||
if (!modifyingCollection) {
|
||||
modifyingCollection = true;
|
||||
@@ -340,7 +340,7 @@ VectorSource.prototype.clear = function(opt_fast) {
|
||||
if (opt_fast) {
|
||||
for (const featureId in this.featureChangeKeys_) {
|
||||
const keys = this.featureChangeKeys_[featureId];
|
||||
keys.forEach(_ol_events_.unlistenByKey);
|
||||
keys.forEach(unlistenByKey);
|
||||
}
|
||||
if (!this.featuresCollection_) {
|
||||
this.featureChangeKeys_ = {};
|
||||
@@ -798,7 +798,7 @@ VectorSource.prototype.removeFeature = function(feature) {
|
||||
*/
|
||||
VectorSource.prototype.removeFeatureInternal = function(feature) {
|
||||
const featureKey = getUid(feature).toString();
|
||||
this.featureChangeKeys_[featureKey].forEach(_ol_events_.unlistenByKey);
|
||||
this.featureChangeKeys_[featureKey].forEach(unlistenByKey);
|
||||
delete this.featureChangeKeys_[featureKey];
|
||||
const id = feature.getId();
|
||||
if (id !== undefined) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import {getUid, inherits} from '../index.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import {assert} from '../asserts.js';
|
||||
import {asArray} from '../color.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen, unlisten} from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import IconAnchorUnits from '../style/IconAnchorUnits.js';
|
||||
import IconImage from '../style/IconImage.js';
|
||||
@@ -354,7 +354,7 @@ Icon.prototype.getSize = function() {
|
||||
* @override
|
||||
*/
|
||||
Icon.prototype.listenImageChange = function(listener, thisArg) {
|
||||
return _ol_events_.listen(this.iconImage_, EventType.CHANGE,
|
||||
return listen(this.iconImage_, EventType.CHANGE,
|
||||
listener, thisArg);
|
||||
};
|
||||
|
||||
@@ -376,7 +376,7 @@ Icon.prototype.load = function() {
|
||||
* @override
|
||||
*/
|
||||
Icon.prototype.unlistenImageChange = function(listener, thisArg) {
|
||||
_ol_events_.unlisten(this.iconImage_, EventType.CHANGE,
|
||||
unlisten(this.iconImage_, EventType.CHANGE,
|
||||
listener, thisArg);
|
||||
};
|
||||
export default Icon;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import {createCanvasContext2D} from '../dom.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listenOnce, unlistenByKey} from '../events.js';
|
||||
import EventTarget from '../events/EventTarget.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
@@ -222,9 +222,9 @@ IconImage.prototype.load = function() {
|
||||
if (this.imageState_ == ImageState.IDLE) {
|
||||
this.imageState_ = ImageState.LOADING;
|
||||
this.imageListenerKeys_ = [
|
||||
_ol_events_.listenOnce(this.image_, EventType.ERROR,
|
||||
listenOnce(this.image_, EventType.ERROR,
|
||||
this.handleImageError_, this),
|
||||
_ol_events_.listenOnce(this.image_, EventType.LOAD,
|
||||
listenOnce(this.image_, EventType.LOAD,
|
||||
this.handleImageLoad_, this)
|
||||
];
|
||||
try {
|
||||
@@ -271,7 +271,7 @@ IconImage.prototype.replaceColor_ = function() {
|
||||
* @private
|
||||
*/
|
||||
IconImage.prototype.unlistenImage_ = function() {
|
||||
this.imageListenerKeys_.forEach(_ol_events_.unlistenByKey);
|
||||
this.imageListenerKeys_.forEach(unlistenByKey);
|
||||
this.imageListenerKeys_ = null;
|
||||
};
|
||||
export default IconImage;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {WEBGL_EXTENSIONS, getUid, inherits} from '../index.js';
|
||||
import Disposable from '../Disposable.js';
|
||||
import {includes} from '../array.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import {listen, unlistenAll} from '../events.js';
|
||||
import {clear} from '../obj.js';
|
||||
import _ol_webgl_ from '../webgl.js';
|
||||
import ContextEventType from '../webgl/ContextEventType.js';
|
||||
@@ -84,9 +84,9 @@ const _ol_webgl_Context_ = function(canvas, gl) {
|
||||
gl.getExtension('OES_element_index_uint');
|
||||
}
|
||||
|
||||
_ol_events_.listen(this.canvas_, ContextEventType.LOST,
|
||||
listen(this.canvas_, ContextEventType.LOST,
|
||||
this.handleWebGLContextLost, this);
|
||||
_ol_events_.listen(this.canvas_, ContextEventType.RESTORED,
|
||||
listen(this.canvas_, ContextEventType.RESTORED,
|
||||
this.handleWebGLContextRestored, this);
|
||||
|
||||
};
|
||||
@@ -145,7 +145,7 @@ _ol_webgl_Context_.prototype.deleteBuffer = function(buf) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
_ol_webgl_Context_.prototype.disposeInternal = function() {
|
||||
_ol_events_.unlistenAll(this.canvas_);
|
||||
unlistenAll(this.canvas_);
|
||||
const gl = this.getGL();
|
||||
if (!gl.isContextLost()) {
|
||||
for (const key in this.bufferCache_) {
|
||||
|
||||
Reference in New Issue
Block a user