Rename ol.interaction.ModifyEvent to ol.interaction.Modify.Event
This commit is contained in:
@@ -24,6 +24,7 @@ A number of internal types have been renamed. This will not affect those who us
|
||||
* rename `ol.interaction.ExtentEventType` to `ol.interaction.Extent.EventType`
|
||||
* rename `ol.interaction.DragAndDropEvent` to `ol.interaction.DragAndDrop.Event`
|
||||
* rename `ol.interaction.DragAndDropEventType` to `ol.interaction.DragAndDrop.EventType`
|
||||
* rename `ol.interaction.ModifyEvent` to `ol.interaction.Modify.Event`
|
||||
* rename `ol.interaction.SelectEvent` to `ol.interaction.Select.Event`
|
||||
* rename `ol.interaction.SelectEventType` to `ol.interaction.Select.EventType`
|
||||
* rename `ol.interaction.TranslateEvent` to `ol.interaction.Translate.Event`
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
goog.provide('ol.interaction.Modify');
|
||||
goog.provide('ol.interaction.ModifyEvent');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.Collection');
|
||||
@@ -29,53 +28,19 @@ goog.require('ol.style.Style');
|
||||
ol.ModifyEventType = {
|
||||
/**
|
||||
* Triggered upon feature modification start
|
||||
* @event ol.interaction.ModifyEvent#modifystart
|
||||
* @event ol.interaction.Modify.Event#modifystart
|
||||
* @api
|
||||
*/
|
||||
MODIFYSTART: 'modifystart',
|
||||
/**
|
||||
* Triggered upon feature modification end
|
||||
* @event ol.interaction.ModifyEvent#modifyend
|
||||
* @event ol.interaction.Modify.Event#modifyend
|
||||
* @api
|
||||
*/
|
||||
MODIFYEND: 'modifyend'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Events emitted by {@link ol.interaction.Modify} instances are instances of
|
||||
* this type.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.events.Event}
|
||||
* @implements {oli.ModifyEvent}
|
||||
* @param {ol.ModifyEventType} type Type.
|
||||
* @param {ol.Collection.<ol.Feature>} features The features modified.
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserPointerEvent Associated
|
||||
* {@link ol.MapBrowserPointerEvent}.
|
||||
*/
|
||||
ol.interaction.ModifyEvent = function(type, features, mapBrowserPointerEvent) {
|
||||
|
||||
ol.events.Event.call(this, type);
|
||||
|
||||
/**
|
||||
* The features being modified.
|
||||
* @type {ol.Collection.<ol.Feature>}
|
||||
* @api
|
||||
*/
|
||||
this.features = features;
|
||||
|
||||
/**
|
||||
* Associated {@link ol.MapBrowserEvent}.
|
||||
* @type {ol.MapBrowserEvent}
|
||||
* @api
|
||||
*/
|
||||
this.mapBrowserEvent = mapBrowserPointerEvent;
|
||||
};
|
||||
ol.inherits(ol.interaction.ModifyEvent, ol.events.Event);
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Interaction for modifying feature geometries.
|
||||
@@ -83,7 +48,7 @@ ol.inherits(ol.interaction.ModifyEvent, ol.events.Event);
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Pointer}
|
||||
* @param {olx.interaction.ModifyOptions} options Options.
|
||||
* @fires ol.interaction.ModifyEvent
|
||||
* @fires ol.interaction.Modify.Event
|
||||
* @api
|
||||
*/
|
||||
ol.interaction.Modify = function(options) {
|
||||
@@ -267,7 +232,7 @@ ol.interaction.Modify.prototype.addFeature_ = function(feature) {
|
||||
ol.interaction.Modify.prototype.willModifyFeatures_ = function(evt) {
|
||||
if (!this.modified_) {
|
||||
this.modified_ = true;
|
||||
this.dispatchEvent(new ol.interaction.ModifyEvent(
|
||||
this.dispatchEvent(new ol.interaction.Modify.Event(
|
||||
ol.ModifyEventType.MODIFYSTART, this.features_, evt));
|
||||
}
|
||||
};
|
||||
@@ -674,7 +639,7 @@ ol.interaction.Modify.handleUpEvent_ = function(evt) {
|
||||
segmentData);
|
||||
}
|
||||
if (this.modified_) {
|
||||
this.dispatchEvent(new ol.interaction.ModifyEvent(
|
||||
this.dispatchEvent(new ol.interaction.Modify.Event(
|
||||
ol.ModifyEventType.MODIFYEND, this.features_, evt));
|
||||
this.modified_ = false;
|
||||
}
|
||||
@@ -872,7 +837,7 @@ ol.interaction.Modify.prototype.removePoint = function() {
|
||||
var evt = this.lastPointerEvent_;
|
||||
this.willModifyFeatures_(evt);
|
||||
handled = this.removeVertex_();
|
||||
this.dispatchEvent(new ol.interaction.ModifyEvent(
|
||||
this.dispatchEvent(new ol.interaction.Modify.Event(
|
||||
ol.ModifyEventType.MODIFYEND, this.features_, evt));
|
||||
this.modified_ = false;
|
||||
}
|
||||
@@ -1040,3 +1005,37 @@ ol.interaction.Modify.getDefaultStyleFunction = function() {
|
||||
return style[ol.geom.GeometryType.POINT];
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Events emitted by {@link ol.interaction.Modify} instances are instances of
|
||||
* this type.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.events.Event}
|
||||
* @implements {oli.ModifyEvent}
|
||||
* @param {ol.ModifyEventType} type Type.
|
||||
* @param {ol.Collection.<ol.Feature>} features The features modified.
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserPointerEvent Associated
|
||||
* {@link ol.MapBrowserPointerEvent}.
|
||||
*/
|
||||
ol.interaction.Modify.Event = function(type, features, mapBrowserPointerEvent) {
|
||||
|
||||
ol.events.Event.call(this, type);
|
||||
|
||||
/**
|
||||
* The features being modified.
|
||||
* @type {ol.Collection.<ol.Feature>}
|
||||
* @api
|
||||
*/
|
||||
this.features = features;
|
||||
|
||||
/**
|
||||
* Associated {@link ol.MapBrowserEvent}.
|
||||
* @type {ol.MapBrowserEvent}
|
||||
* @api
|
||||
*/
|
||||
this.mapBrowserEvent = mapBrowserPointerEvent;
|
||||
};
|
||||
ol.inherits(ol.interaction.Modify.Event, ol.events.Event);
|
||||
|
||||
@@ -11,7 +11,6 @@ goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.geom.Polygon');
|
||||
goog.require('ol.interaction.Modify');
|
||||
goog.require('ol.interaction.ModifyEvent');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.pointer.PointerEvent');
|
||||
goog.require('ol.source.Vector');
|
||||
@@ -102,7 +101,7 @@ describe('ol.interaction.Modify', function() {
|
||||
* modifications. Helper function to
|
||||
* @param {ol.Feature} feature Modified feature.
|
||||
* @param {ol.interaction.Modify} interaction The interaction.
|
||||
* @return {Array<ol.interaction.ModifyEvent|string>} events
|
||||
* @return {Array<ol.interaction.Modify.Event|string>} events
|
||||
*/
|
||||
function trackEvents(feature, interaction) {
|
||||
var events = [];
|
||||
@@ -122,7 +121,7 @@ describe('ol.interaction.Modify', function() {
|
||||
* Validates the event array to verify proper event sequence. Checks
|
||||
* that first and last event are correct ModifyEvents and that feature
|
||||
* modifications event are in between.
|
||||
* @param {Array<ol.interaction.ModifyEvent|string>} events The events.
|
||||
* @param {Array<ol.interaction.Modify.Event|string>} events The events.
|
||||
* @param {Array<ol.Feature>} features The features.
|
||||
*/
|
||||
function validateEvents(events, features) {
|
||||
@@ -131,11 +130,11 @@ describe('ol.interaction.Modify', function() {
|
||||
var endevent = events[events.length - 1];
|
||||
|
||||
// first event should be modifystary
|
||||
expect(startevent).to.be.an(ol.interaction.ModifyEvent);
|
||||
expect(startevent).to.be.an(ol.interaction.Modify.Event);
|
||||
expect(startevent.type).to.eql('modifystart');
|
||||
|
||||
// last event should be modifyend
|
||||
expect(endevent).to.be.an(ol.interaction.ModifyEvent);
|
||||
expect(endevent).to.be.an(ol.interaction.Modify.Event);
|
||||
expect(endevent.type).to.eql('modifyend');
|
||||
|
||||
// make sure we get change events to events array
|
||||
|
||||
Reference in New Issue
Block a user