Add 'translatestart', 'translateend' and 'translatedrag' events to 'ol.interaction.Translate'

This commit is contained in:
jonataswalker
2015-09-23 19:19:26 -03:00
parent 0188809918
commit 9a923cc5dc
2 changed files with 33 additions and 22 deletions

View File

@@ -211,6 +211,25 @@ oli.interaction.DragAndDropEvent.prototype.projection;
oli.interaction.DragAndDropEvent.prototype.file; oli.interaction.DragAndDropEvent.prototype.file;
/**
* @interface
*/
oli.interaction.TranslateEvent = function() {};
/**
* @type {ol.Collection.<ol.Feature>}
*/
oli.interaction.TranslateEvent.prototype.features;
/**
* @type {ol.Coordinate}
*/
oli.interaction.TranslateEvent.prototype.coordinate;
/** /**
* @type {Object} * @type {Object}
*/ */

View File

@@ -4,15 +4,13 @@ goog.provide('ol.interaction.TranslateEvent');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.events'); goog.require('goog.events');
goog.require('goog.events.Event'); goog.require('goog.events.Event');
goog.require('goog.events.EventType');
goog.require('ol.MapBrowserEvent.EventType');
goog.require('ol.interaction.Pointer'); goog.require('ol.interaction.Pointer');
/** /**
* @enum {string} * @enum {string}
*/ */
ol.TranslateEventType = { ol.interaction.TranslateEventType = {
/** /**
* Triggered upon feature translation start * Triggered upon feature translation start
* @event ol.interaction.TranslateEvent#translatestart * @event ol.interaction.TranslateEvent#translatestart
@@ -42,15 +40,12 @@ ol.TranslateEventType = {
* *
* @constructor * @constructor
* @extends {goog.events.Event} * @extends {goog.events.Event}
* @implements {oli.TranslateEvent} * @implements {oli.interaction.TranslateEvent}
* @param {ol.TranslateEventType} type Type. * @param {ol.interaction.TranslateEventType} type Type.
* @param {ol.Collection.<ol.Feature>} features The features translated. * @param {ol.Collection.<ol.Feature>} features The features translated.
* @param {ol.Coordinate} coordinate The event coordinate. * @param {ol.Coordinate} coordinate The event coordinate.
* @param {ol.MapBrowserPointerEvent} mapBrowserPointerEvent Associated
* {@link ol.MapBrowserPointerEvent}.
*/ */
ol.interaction.TranslateEvent = ol.interaction.TranslateEvent = function(type, features, coordinate) {
function(type, features, coordinate, mapBrowserPointerEvent) {
goog.base(this, type); goog.base(this, type);
@@ -68,13 +63,6 @@ ol.interaction.TranslateEvent =
* @api * @api
*/ */
this.coordinate = coordinate; this.coordinate = coordinate;
/**
* Associated {@link ol.MapBrowserPointerEvent}.
* @type {ol.MapBrowserPointerEvent}
* @api
*/
this.mapBrowserPointerEvent = mapBrowserPointerEvent;
}; };
goog.inherits(ol.interaction.TranslateEvent, goog.events.Event); goog.inherits(ol.interaction.TranslateEvent, goog.events.Event);
@@ -86,6 +74,7 @@ goog.inherits(ol.interaction.TranslateEvent, goog.events.Event);
* *
* @constructor * @constructor
* @extends {ol.interaction.Pointer} * @extends {ol.interaction.Pointer}
* @fires ol.interaction.TranslateEvent
* @param {olx.interaction.TranslateOptions} options Options. * @param {olx.interaction.TranslateOptions} options Options.
* @api * @api
*/ */
@@ -140,8 +129,9 @@ ol.interaction.Translate.handleDownEvent_ = function(event) {
this.lastCoordinate_ = event.coordinate; this.lastCoordinate_ = event.coordinate;
ol.interaction.Translate.handleMoveEvent_.call(this, event); ol.interaction.Translate.handleMoveEvent_.call(this, event);
this.dispatchEvent( this.dispatchEvent(
new ol.interaction.TranslateEvent(ol.TranslateEventType.TRANSLATESTART, new ol.interaction.TranslateEvent(
this.features_, event.coordinate)); ol.interaction.TranslateEventType.TRANSLATESTART, this.features_,
event.coordinate));
return true; return true;
} }
return false; return false;
@@ -159,8 +149,9 @@ ol.interaction.Translate.handleUpEvent_ = function(event) {
this.lastCoordinate_ = null; this.lastCoordinate_ = null;
ol.interaction.Translate.handleMoveEvent_.call(this, event); ol.interaction.Translate.handleMoveEvent_.call(this, event);
this.dispatchEvent( this.dispatchEvent(
new ol.interaction.TranslateEvent(ol.TranslateEventType.TRANSLATEEND, new ol.interaction.TranslateEvent(
this.features_, event.coordinate)); ol.interaction.TranslateEventType.TRANSLATEEND, this.features_,
event.coordinate));
return true; return true;
} }
return false; return false;
@@ -193,8 +184,9 @@ ol.interaction.Translate.handleDragEvent_ = function(event) {
this.lastCoordinate_ = newCoordinate; this.lastCoordinate_ = newCoordinate;
this.dispatchEvent( this.dispatchEvent(
new ol.interaction.TranslateEvent(ol.TranslateEventType.TRANSLATEDRAG, new ol.interaction.TranslateEvent(
this.features_, newCoordinate)); ol.interaction.TranslateEventType.TRANSLATEDRAG, this.features_,
newCoordinate));
} }
}; };