X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/54aa89a4bf8118a3fdec2d60acba6aeb7beaa8c8..d065f88b1a565d1b9c784d27993159bc64c926ec:/app/assets/javascripts/index/directions.js diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index ae01cb566..4e2c4a895 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -21,9 +21,11 @@ OSM.Directions = function (map) { }); var endpointDragCallback = function (dragging) { - if (map.hasLayer(polyline)) { - getRoute(false, !dragging); - } + if (!map.hasLayer(polyline)) return; + if (dragging && !chosenEngine.draggable) return; + if (dragging && awaitingRoute) return; + + getRoute(false, !dragging); }; var endpointGeocodeCallback = function () { getRoute(true, true); @@ -68,11 +70,8 @@ OSM.Directions = function (map) { }); endpoint.marker.on("drag dragend", function (e) { - var dragging = (e.type === "drag"); - if (dragging && !chosenEngine.draggable) return; - if (dragging && awaitingRoute) return; endpoint.setLatLng(e.target.getLatLng()); - dragCallback(dragging); + dragCallback(e.type === "drag"); }); input.on("keydown", function () {