Add a 'condition' option to ol.interaction.Modify

This commit is contained in:
Frederic Junod
2016-05-09 17:13:22 +02:00
parent 8c8c4c3df4
commit b49546d2af
4 changed files with 59 additions and 2 deletions

View File

@@ -112,6 +112,14 @@ ol.interaction.Modify = function(options) {
handleUpEvent: ol.interaction.Modify.handleUpEvent_
});
/**
* @private
* @type {ol.events.ConditionType}
*/
this.condition_ = options.condition ?
options.condition : ol.events.condition.primaryAction;
/**
* @private
* @param {ol.MapBrowserEvent} mapBrowserEvent Browser event.
@@ -553,6 +561,9 @@ ol.interaction.Modify.compareIndexes_ = function(a, b) {
* @private
*/
ol.interaction.Modify.handleDownEvent_ = function(evt) {
if (!this.condition_(evt)) {
return false;
}
this.handlePointerAtPixel_(evt.pixel, evt.map);
this.dragSegments_.length = 0;
this.modified_ = false;