Fix dragend: update waypoint through proxy, not stale closure reference
This commit is contained in:
+5
-3
@@ -75,9 +75,11 @@
|
|||||||
const wp = { lng, lat, marker };
|
const wp = { lng, lat, marker };
|
||||||
marker.on('dragend', () => {
|
marker.on('dragend', () => {
|
||||||
const { lng: newLng, lat: newLat } = marker.getLngLat();
|
const { lng: newLng, lat: newLat } = marker.getLngLat();
|
||||||
wp.lng = newLng;
|
const i = waypoints.findIndex(w => w.marker === marker);
|
||||||
wp.lat = newLat;
|
if (i >= 0) {
|
||||||
waypoints = waypoints; // trigger reactivity
|
waypoints[i].lng = newLng;
|
||||||
|
waypoints[i].lat = newLat;
|
||||||
|
}
|
||||||
fetchRoute();
|
fetchRoute();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user