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.
This commit is contained in:
Anton Khorev 2024-08-10 05:53:59 +03:00
parent 6b179c4e9b
commit d065f88b1a

View file

@ -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 () {