mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-12-02 10:02:12 +00:00
cancel drag on click
This commit is contained in:
@@ -90,6 +90,7 @@ export class GPXLayer {
|
|||||||
selected: boolean = false;
|
selected: boolean = false;
|
||||||
currentWaypointData: GeoJSON.FeatureCollection | null = null;
|
currentWaypointData: GeoJSON.FeatureCollection | null = null;
|
||||||
draggedWaypointIndex: number | null = null;
|
draggedWaypointIndex: number | null = null;
|
||||||
|
draggingStartingPosition: mapboxgl.Point = new mapboxgl.Point(0, 0);
|
||||||
unsubscribe: Function[] = [];
|
unsubscribe: Function[] = [];
|
||||||
|
|
||||||
updateBinded: () => void = this.update.bind(this);
|
updateBinded: () => void = this.update.bind(this);
|
||||||
@@ -544,7 +545,7 @@ export class GPXLayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
waypointLayerOnMouseDown(e: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent) {
|
waypointLayerOnMouseDown(e: mapboxgl.MapMouseEvent) {
|
||||||
if (get(currentTool) !== Tool.WAYPOINT || !this.selected) {
|
if (get(currentTool) !== Tool.WAYPOINT || !this.selected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -556,6 +557,7 @@ export class GPXLayer {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
this.draggedWaypointIndex = e.features![0].properties!.waypointIndex;
|
this.draggedWaypointIndex = e.features![0].properties!.waypointIndex;
|
||||||
|
this.draggingStartingPosition = e.point;
|
||||||
waypointPopup?.hide();
|
waypointPopup?.hide();
|
||||||
|
|
||||||
_map.on('mousemove', this.waypointLayerOnMouseMoveBinded);
|
_map.on('mousemove', this.waypointLayerOnMouseMoveBinded);
|
||||||
@@ -574,7 +576,7 @@ export class GPXLayer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let features = _map.queryRenderedFeatures(e.points[0], {
|
let features = _map.queryRenderedFeatures(e.point, {
|
||||||
layers: [this.fileId + '-waypoints'],
|
layers: [this.fileId + '-waypoints'],
|
||||||
});
|
});
|
||||||
if (features.length === 0) {
|
if (features.length === 0) {
|
||||||
@@ -582,6 +584,7 @@ export class GPXLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.draggedWaypointIndex = features[0].properties!.waypointIndex;
|
this.draggedWaypointIndex = features[0].properties!.waypointIndex;
|
||||||
|
this.draggingStartingPosition = e.point;
|
||||||
waypointPopup?.hide();
|
waypointPopup?.hide();
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -591,7 +594,7 @@ export class GPXLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
waypointLayerOnMouseMove(e: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent) {
|
waypointLayerOnMouseMove(e: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent) {
|
||||||
if (!this.draggedWaypointIndex) {
|
if (!this.draggedWaypointIndex || e.point.equals(this.draggingStartingPosition)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -618,6 +621,10 @@ export class GPXLayer {
|
|||||||
if (this.draggedWaypointIndex === null) {
|
if (this.draggedWaypointIndex === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (e.point.equals(this.draggingStartingPosition)) {
|
||||||
|
this.draggedWaypointIndex = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
getElevation([
|
getElevation([
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user