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;
|
||||
currentWaypointData: GeoJSON.FeatureCollection | null = null;
|
||||
draggedWaypointIndex: number | null = null;
|
||||
draggingStartingPosition: mapboxgl.Point = new mapboxgl.Point(0, 0);
|
||||
unsubscribe: Function[] = [];
|
||||
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
@@ -556,6 +557,7 @@ export class GPXLayer {
|
||||
e.preventDefault();
|
||||
|
||||
this.draggedWaypointIndex = e.features![0].properties!.waypointIndex;
|
||||
this.draggingStartingPosition = e.point;
|
||||
waypointPopup?.hide();
|
||||
|
||||
_map.on('mousemove', this.waypointLayerOnMouseMoveBinded);
|
||||
@@ -574,7 +576,7 @@ export class GPXLayer {
|
||||
return;
|
||||
}
|
||||
|
||||
let features = _map.queryRenderedFeatures(e.points[0], {
|
||||
let features = _map.queryRenderedFeatures(e.point, {
|
||||
layers: [this.fileId + '-waypoints'],
|
||||
});
|
||||
if (features.length === 0) {
|
||||
@@ -582,6 +584,7 @@ export class GPXLayer {
|
||||
}
|
||||
|
||||
this.draggedWaypointIndex = features[0].properties!.waypointIndex;
|
||||
this.draggingStartingPosition = e.point;
|
||||
waypointPopup?.hide();
|
||||
|
||||
e.preventDefault();
|
||||
@@ -591,7 +594,7 @@ export class GPXLayer {
|
||||
}
|
||||
|
||||
waypointLayerOnMouseMove(e: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent) {
|
||||
if (!this.draggedWaypointIndex) {
|
||||
if (!this.draggedWaypointIndex || e.point.equals(this.draggingStartingPosition)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -618,6 +621,10 @@ export class GPXLayer {
|
||||
if (this.draggedWaypointIndex === null) {
|
||||
return;
|
||||
}
|
||||
if (e.point.equals(this.draggingStartingPosition)) {
|
||||
this.draggedWaypointIndex = null;
|
||||
return;
|
||||
}
|
||||
|
||||
getElevation([
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user