From 56067d1cdaeb1262258bff3a1e08038e11686ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=20Peru=C4=8Di=C4=87?= Date: Wed, 25 Mar 2015 11:00:13 +0100 Subject: [PATCH] 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 --- examples/modify-test.js | 4 ++-- src/ol/interaction/modifyinteraction.js | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/modify-test.js b/examples/modify-test.js index 4db5d02869..1d88793c46 100644 --- a/examples/modify-test.js +++ b/examples/modify-test.js @@ -115,7 +115,7 @@ var source = new ol.source.GeoJSON( 'coordinates': [ [[-1e6, -7.5e5], [-1e6, 7.5e5]], [[-1e6, -7.5e5], [-1e6, 7.5e5], [-5e5, 0], [-1e6, -7.5e5]], - [[1e6, -7.5e5], [15e5, 0], [15e5, 0], [1e6, 7.5e5]], + [[1e6, -7.5e5], [15e5, 0], [15e5, 0], [1e6, 7.5e5]], [[-7.5e5, -1e6], [7.5e5, -1e6]], [[-7.5e5, 1e6], [7.5e5, 1e6]] ] @@ -129,7 +129,7 @@ var source = new ol.source.GeoJSON( [[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6], [-3e6, 6e6], [-5e6, 6e6]]], [[[-3e6, 6e6], [-2e6, 8e6], [0, 8e6], - [0, 6e6], [-3e6, 6e6] ]], + [0, 6e6], [-3e6, 6e6]]], [[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6], [3e6, 6e6], [1e6, 6e6]]] ] diff --git a/src/ol/interaction/modifyinteraction.js b/src/ol/interaction/modifyinteraction.js index 49cb4d23a5..d37703be56 100644 --- a/src/ol/interaction/modifyinteraction.js +++ b/src/ol/interaction/modifyinteraction.js @@ -436,11 +436,11 @@ ol.interaction.Modify.handleDownEvent_ = function(evt) { // prevent dragging closed linestrings by the connecting node if ((segmentDataMatch.geometry.getType() === - ol.geom.GeometryType.LINE_STRING || - segmentDataMatch.geometry.getType() === - ol.geom.GeometryType.MULTI_LINE_STRING) && - componentSegments[uid][0] && - componentSegments[uid][0].index === 0) { + ol.geom.GeometryType.LINE_STRING || + segmentDataMatch.geometry.getType() === + ol.geom.GeometryType.MULTI_LINE_STRING) && + componentSegments[uid][0] && + componentSegments[uid][0].index === 0) { continue; } @@ -507,8 +507,8 @@ ol.interaction.Modify.handleDragEvent_ = function(evt) { } 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) { var handled; 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); } if (!goog.isNull(this.vertexFeature_) &&