Prevent unnecessary function calls

handlePointerMove_ doesn't need to be called when dragging.
handleDragEvent_ takes care of the event in that case.

in handleDragEvent_, createOrUpdateVertexFeature_ doesn't need to be called for each dragged segment. it can be called only once with current vertex.

fixes made to pass the build
This commit is contained in:
Fran Peručić
2015-03-25 11:00:13 +01:00
parent 279d1829bb
commit 56067d1cda
2 changed files with 10 additions and 9 deletions
+1 -1
View File
@@ -129,7 +129,7 @@ var source = new ol.source.GeoJSON(
[[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6], [[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6],
[-3e6, 6e6], [-5e6, 6e6]]], [-3e6, 6e6], [-5e6, 6e6]]],
[[[-3e6, 6e6], [-2e6, 8e6], [0, 8e6], [[[-3e6, 6e6], [-2e6, 8e6], [0, 8e6],
[0, 6e6], [-3e6, 6e6] ]], [0, 6e6], [-3e6, 6e6]]],
[[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6], [[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6],
[3e6, 6e6], [1e6, 6e6]]] [3e6, 6e6], [1e6, 6e6]]]
] ]
+3 -2
View File
@@ -507,8 +507,8 @@ ol.interaction.Modify.handleDragEvent_ = function(evt) {
} }
geometry.setCoordinates(coordinates); geometry.setCoordinates(coordinates);
this.createOrUpdateVertexFeature_(vertex);
} }
this.createOrUpdateVertexFeature_(vertex);
}; };
@@ -538,7 +538,8 @@ ol.interaction.Modify.handleUpEvent_ = function(evt) {
ol.interaction.Modify.handleEvent = function(mapBrowserEvent) { ol.interaction.Modify.handleEvent = function(mapBrowserEvent) {
var handled; var handled;
if (!mapBrowserEvent.map.getView().getHints()[ol.ViewHint.INTERACTING] && if (!mapBrowserEvent.map.getView().getHints()[ol.ViewHint.INTERACTING] &&
mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERMOVE) { mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERMOVE &&
!this.handlingDownUpSequence) {
this.handlePointerMove_(mapBrowserEvent); this.handlePointerMove_(mapBrowserEvent);
} }
if (!goog.isNull(this.vertexFeature_) && if (!goog.isNull(this.vertexFeature_) &&