From: Anton Khorev Date: Sat, 10 Aug 2024 02:53:59 +0000 (+0300) Subject: Remove references to global variables from endpoint drag listener X-Git-Tag: live~310^2~2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/d065f88b1a565d1b9c784d27993159bc64c926ec Remove references to global variables from endpoint drag listener This causes visible input value updates even when the route is not recalculated. The upside is that it lets endpoints not know about the route and its update state. --- 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 () {