Remove static members from Translate
This commit is contained in:
@@ -10,7 +10,67 @@ import {TRUE} from '../functions.js';
|
|||||||
import {includes} from '../array.js';
|
import {includes} from '../array.js';
|
||||||
import PointerInteraction from '../interaction/Pointer.js';
|
import PointerInteraction from '../interaction/Pointer.js';
|
||||||
import InteractionProperty from '../interaction/Property.js';
|
import InteractionProperty from '../interaction/Property.js';
|
||||||
import TranslateEventType from '../interaction/TranslateEventType.js';
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
const TranslateEventType = {
|
||||||
|
/**
|
||||||
|
* Triggered upon feature translation start.
|
||||||
|
* @event TranslateEvent#translatestart
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
TRANSLATESTART: 'translatestart',
|
||||||
|
/**
|
||||||
|
* Triggered upon feature translation.
|
||||||
|
* @event TranslateEvent#translating
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
TRANSLATING: 'translating',
|
||||||
|
/**
|
||||||
|
* Triggered upon feature translation end.
|
||||||
|
* @event TranslateEvent#translateend
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
TRANSLATEEND: 'translateend'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @classdesc
|
||||||
|
* Events emitted by {@link ol.interaction.Translate} instances are instances of
|
||||||
|
* this type.
|
||||||
|
*
|
||||||
|
* @constructor
|
||||||
|
* @extends {ol.events.Event}
|
||||||
|
* @implements {oli.interaction.TranslateEvent}
|
||||||
|
* @param {ol.interaction.TranslateEventType} type Type.
|
||||||
|
* @param {ol.Collection.<ol.Feature>} features The features translated.
|
||||||
|
* @param {ol.Coordinate} coordinate The event coordinate.
|
||||||
|
*/
|
||||||
|
export const TranslateEvent = function(type, features, coordinate) {
|
||||||
|
|
||||||
|
Event.call(this, type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The features being translated.
|
||||||
|
* @type {ol.Collection.<ol.Feature>}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
this.features = features;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The coordinate of the drag event.
|
||||||
|
* @const
|
||||||
|
* @type {ol.Coordinate}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
this.coordinate = coordinate;
|
||||||
|
};
|
||||||
|
|
||||||
|
inherits(TranslateEvent, Event);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @classdesc
|
* @classdesc
|
||||||
@@ -18,7 +78,7 @@ import TranslateEventType from '../interaction/TranslateEventType.js';
|
|||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.interaction.Pointer}
|
* @extends {ol.interaction.Pointer}
|
||||||
* @fires ol.interaction.Translate.Event
|
* @fires ol.interaction.TranslateEvent
|
||||||
* @param {olx.interaction.TranslateOptions=} opt_options Options.
|
* @param {olx.interaction.TranslateOptions=} opt_options Options.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
@@ -102,7 +162,7 @@ function handleDownEvent(event) {
|
|||||||
const features = this.features_ || new Collection([this.lastFeature_]);
|
const features = this.features_ || new Collection([this.lastFeature_]);
|
||||||
|
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new Translate.Event(
|
new TranslateEvent(
|
||||||
TranslateEventType.TRANSLATESTART, features,
|
TranslateEventType.TRANSLATESTART, features,
|
||||||
event.coordinate));
|
event.coordinate));
|
||||||
return true;
|
return true;
|
||||||
@@ -124,7 +184,7 @@ function handleUpEvent(event) {
|
|||||||
const features = this.features_ || new Collection([this.lastFeature_]);
|
const features = this.features_ || new Collection([this.lastFeature_]);
|
||||||
|
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new Translate.Event(
|
new TranslateEvent(
|
||||||
TranslateEventType.TRANSLATEEND, features,
|
TranslateEventType.TRANSLATEEND, features,
|
||||||
event.coordinate));
|
event.coordinate));
|
||||||
return true;
|
return true;
|
||||||
@@ -153,7 +213,7 @@ function handleDragEvent(event) {
|
|||||||
|
|
||||||
this.lastCoordinate_ = newCoordinate;
|
this.lastCoordinate_ = newCoordinate;
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new Translate.Event(
|
new TranslateEvent(
|
||||||
TranslateEventType.TRANSLATING, features,
|
TranslateEventType.TRANSLATING, features,
|
||||||
newCoordinate));
|
newCoordinate));
|
||||||
}
|
}
|
||||||
@@ -257,38 +317,4 @@ Translate.prototype.updateState_ = function(oldMap) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @classdesc
|
|
||||||
* Events emitted by {@link ol.interaction.Translate} instances are instances of
|
|
||||||
* this type.
|
|
||||||
*
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.events.Event}
|
|
||||||
* @implements {oli.interaction.TranslateEvent}
|
|
||||||
* @param {ol.interaction.TranslateEventType} type Type.
|
|
||||||
* @param {ol.Collection.<ol.Feature>} features The features translated.
|
|
||||||
* @param {ol.Coordinate} coordinate The event coordinate.
|
|
||||||
*/
|
|
||||||
Translate.Event = function(type, features, coordinate) {
|
|
||||||
|
|
||||||
Event.call(this, type);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The features being translated.
|
|
||||||
* @type {ol.Collection.<ol.Feature>}
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
this.features = features;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The coordinate of the drag event.
|
|
||||||
* @const
|
|
||||||
* @type {ol.Coordinate}
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
this.coordinate = coordinate;
|
|
||||||
};
|
|
||||||
|
|
||||||
inherits(Translate.Event, Event);
|
|
||||||
|
|
||||||
export default Translate;
|
export default Translate;
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
/**
|
|
||||||
* @module ol/interaction/TranslateEventType
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
export default {
|
|
||||||
/**
|
|
||||||
* Triggered upon feature translation start.
|
|
||||||
* @event ol.interaction.Translate.Event#translatestart
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
TRANSLATESTART: 'translatestart',
|
|
||||||
/**
|
|
||||||
* Triggered upon feature translation.
|
|
||||||
* @event ol.interaction.Translate.Event#translating
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
TRANSLATING: 'translating',
|
|
||||||
/**
|
|
||||||
* Triggered upon feature translation end.
|
|
||||||
* @event ol.interaction.Translate.Event#translateend
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
TRANSLATEEND: 'translateend'
|
|
||||||
};
|
|
||||||
@@ -4,7 +4,7 @@ import Map from '../../../../src/ol/Map.js';
|
|||||||
import MapBrowserPointerEvent from '../../../../src/ol/MapBrowserPointerEvent.js';
|
import MapBrowserPointerEvent from '../../../../src/ol/MapBrowserPointerEvent.js';
|
||||||
import View from '../../../../src/ol/View.js';
|
import View from '../../../../src/ol/View.js';
|
||||||
import Point from '../../../../src/ol/geom/Point.js';
|
import Point from '../../../../src/ol/geom/Point.js';
|
||||||
import Translate from '../../../../src/ol/interaction/Translate.js';
|
import Translate, {TranslateEvent} from '../../../../src/ol/interaction/Translate.js';
|
||||||
import Interaction from '../../../../src/ol/interaction/Interaction.js';
|
import Interaction from '../../../../src/ol/interaction/Interaction.js';
|
||||||
import VectorLayer from '../../../../src/ol/layer/Vector.js';
|
import VectorLayer from '../../../../src/ol/layer/Vector.js';
|
||||||
import PointerEvent from '../../../../src/ol/pointer/PointerEvent.js';
|
import PointerEvent from '../../../../src/ol/pointer/PointerEvent.js';
|
||||||
@@ -80,7 +80,7 @@ describe('ol.interaction.Translate', function() {
|
|||||||
* modifications. Helper function to
|
* modifications. Helper function to
|
||||||
* @param {ol.Feature} feature Translated feature.
|
* @param {ol.Feature} feature Translated feature.
|
||||||
* @param {ol.interaction.Translate} interaction The interaction.
|
* @param {ol.interaction.Translate} interaction The interaction.
|
||||||
* @return {Array<ol.interaction.Translate.Event|string>} events
|
* @return {Array<TranslateEvent|string>} events
|
||||||
*/
|
*/
|
||||||
function trackEvents(feature, interaction) {
|
function trackEvents(feature, interaction) {
|
||||||
const events = [];
|
const events = [];
|
||||||
@@ -100,7 +100,7 @@ describe('ol.interaction.Translate', function() {
|
|||||||
* Validates the event array to verify proper event sequence. Checks
|
* Validates the event array to verify proper event sequence. Checks
|
||||||
* that first and last event are correct TranslateEvents and that feature
|
* that first and last event are correct TranslateEvents and that feature
|
||||||
* modifications event are in between.
|
* modifications event are in between.
|
||||||
* @param {Array<ol.interaction.Translate.Event|string>} events The events.
|
* @param {Array<TranslateEvent|string>} events The events.
|
||||||
* @param {Array<ol.Feature>} features The features.
|
* @param {Array<ol.Feature>} features The features.
|
||||||
*/
|
*/
|
||||||
function validateEvents(events, features) {
|
function validateEvents(events, features) {
|
||||||
@@ -109,11 +109,11 @@ describe('ol.interaction.Translate', function() {
|
|||||||
const endevent = events[events.length - 1];
|
const endevent = events[events.length - 1];
|
||||||
|
|
||||||
// first event should be translatestart
|
// first event should be translatestart
|
||||||
expect(startevent).to.be.an(Translate.Event);
|
expect(startevent).to.be.an(TranslateEvent);
|
||||||
expect(startevent.type).to.eql('translatestart');
|
expect(startevent.type).to.eql('translatestart');
|
||||||
|
|
||||||
// last event should be translateend
|
// last event should be translateend
|
||||||
expect(endevent).to.be.an(Translate.Event);
|
expect(endevent).to.be.an(TranslateEvent);
|
||||||
expect(endevent.type).to.eql('translateend');
|
expect(endevent.type).to.eql('translateend');
|
||||||
|
|
||||||
// make sure we get change events to events array
|
// make sure we get change events to events array
|
||||||
|
|||||||
Reference in New Issue
Block a user