mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-12-02 10:02:12 +00:00
listen to touchstart event on layer
This commit is contained in:
@@ -241,7 +241,11 @@ export class GPXLayer {
|
|||||||
this.fileId + '-waypoints',
|
this.fileId + '-waypoints',
|
||||||
this.waypointLayerOnMouseDownBinded
|
this.waypointLayerOnMouseDownBinded
|
||||||
);
|
);
|
||||||
_map.on('touchstart', this.waypointLayerOnTouchStartBinded);
|
_map.on(
|
||||||
|
'touchstart',
|
||||||
|
this.fileId + '-waypoints',
|
||||||
|
this.waypointLayerOnTouchStartBinded
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get(directionMarkers)) {
|
if (get(directionMarkers)) {
|
||||||
@@ -569,10 +573,7 @@ export class GPXLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
waypointLayerOnTouchStart(e: mapboxgl.MapTouchEvent) {
|
waypointLayerOnTouchStart(e: mapboxgl.MapTouchEvent) {
|
||||||
if (e.points.length !== 1) {
|
if (e.points.length !== 1 || get(currentTool) !== Tool.WAYPOINT || !this.selected) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (get(currentTool) !== Tool.WAYPOINT || !this.selected) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const _map = get(map);
|
const _map = get(map);
|
||||||
@@ -580,14 +581,7 @@ export class GPXLayer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let features = _map.queryRenderedFeatures(e.point, {
|
this.draggedWaypointIndex = e.features![0].properties!.waypointIndex;
|
||||||
layers: [this.fileId + '-waypoints'],
|
|
||||||
});
|
|
||||||
if (features.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.draggedWaypointIndex = features[0].properties!.waypointIndex;
|
|
||||||
this.draggingStartingPosition = e.point;
|
this.draggingStartingPosition = e.point;
|
||||||
waypointPopup?.hide();
|
waypointPopup?.hide();
|
||||||
|
|
||||||
@@ -598,10 +592,7 @@ export class GPXLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
waypointLayerOnMouseMove(e: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent) {
|
waypointLayerOnMouseMove(e: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent) {
|
||||||
if (
|
if (!this.draggedWaypointIndex || e.point.equals(this.draggingStartingPosition)) {
|
||||||
!this.draggedWaypointIndex ||
|
|
||||||
(e.type === 'mousemove' && e.point.equals(this.draggingStartingPosition))
|
|
||||||
) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user