Merge pull request #1348 from tschaub/beforechange
Add `ol.ObjectEvent` for changes to `ol.Object` properties. Previously, `ol.Object` dispatched instances of `goog.events.Event` with type `change`. Now `ol.ObjectEvent` instances will be dispatched on property changes. The events include a `getKey` method to get the name of the property being changed. The `beforepropertychange` type event is fired before a property value changes, and the `propertychange` type event fires after the property value changes.
This commit is contained in:
@@ -10,6 +10,7 @@ goog.require('ol.Collection');
|
||||
goog.require('ol.CollectionEvent');
|
||||
goog.require('ol.CollectionEventType');
|
||||
goog.require('ol.Object');
|
||||
goog.require('ol.ObjectEventType');
|
||||
goog.require('ol.layer.Base');
|
||||
goog.require('ol.source.State');
|
||||
|
||||
@@ -104,7 +105,8 @@ ol.layer.Group.prototype.handleLayersChanged_ = function(event) {
|
||||
for (i = 0, ii = layersArray.length; i < ii; i++) {
|
||||
layer = layersArray[i];
|
||||
this.listenerKeys_[goog.getUid(layer).toString()] =
|
||||
goog.events.listen(layer, goog.events.EventType.CHANGE,
|
||||
goog.events.listen(layer,
|
||||
[ol.ObjectEventType.PROPERTYCHANGE, goog.events.EventType.CHANGE],
|
||||
this.handleLayerChange_, false, this);
|
||||
}
|
||||
}
|
||||
@@ -120,8 +122,8 @@ ol.layer.Group.prototype.handleLayersChanged_ = function(event) {
|
||||
ol.layer.Group.prototype.handleLayersAdd_ = function(collectionEvent) {
|
||||
var layer = /** @type {ol.layer.Base} */ (collectionEvent.getElement());
|
||||
this.listenerKeys_[goog.getUid(layer).toString()] = goog.events.listen(
|
||||
layer, goog.events.EventType.CHANGE, this.handleLayerChange_, false,
|
||||
this);
|
||||
layer, [ol.ObjectEventType.PROPERTYCHANGE, goog.events.EventType.CHANGE],
|
||||
this.handleLayerChange_, false, this);
|
||||
this.dispatchChangeEvent();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user