Skip to content

fix: enable template drawing on touch devices - #64

Closed
MyrkoF wants to merge 1 commit into
fcsonline:mainfrom
MyrkoF:feat/touch-template-drawing
Closed

MyrkoF wants to merge 1 commit into
fcsonline:mainfrom
MyrkoF:feat/touch-template-drawing

Conversation

@MyrkoF

@MyrkoF MyrkoF commented Jul 30, 2026

Copy link
Copy Markdown

Problem

The mission templates (Orbit, Grid, Facade, Pencil) are drawn with a select-and-drag gesture on the map. The drag handlers in TemplateDrawHandler and PencilDrawHandler only listen to mousedown / mousemove / mouseup, so on a tablet or phone the drawing gesture never fires — the touch is swallowed by the map's pan handler. In practice the templates are unusable on touch devices, which is exactly the field use case (planning a mission on a tablet on site).

Fix

Add touchstart / touchmove / touchend handlers that mirror the existing mouse flow, alongside the mouse handlers (which are left byte-for-byte unchanged):

  • One finger draws the template. preventDefault() on the touchstart event suppresses the map's own DragPanHandler / two-finger zoom for that gesture only (per MapLibre/Mapbox MapTouchEvent.preventDefault() semantics), so the pan no longer eats the draw.
  • Two or more fingers (e.points.length > 1) are left untouched, so native pinch-zoom / pan keeps working.
  • Lifting the finger commits the drawing, just like mouseup. On touchend, lngLat is derived from the lifted finger (changedTouches), which is the correct commit position.

No change to the desktop / mouse path, and no new dependencies. Pencil (freehand) benefits from the same mechanism.

Testing

  • npm run lint, npm run build and npm run test -w packages/backend all pass.
  • Verified the mouse path is unchanged (additive touch handlers only).

🤖 Generated with Claude Code

Orbit, Grid, Facade and Pencil templates could only be drawn with a
mouse: the drag-to-draw handlers listened to mousedown/mousemove/mouseup,
while on touch devices the gesture was swallowed by the map pan, leaving
the templates unusable on tablets and phones.

This adds touchstart/touchmove/touchend handlers that mirror the existing
mouse flow. A single finger draws the template — preventDefault() on
touchstart suppresses the map's own pan for that gesture only — while two
or more fingers are left to the native pinch-zoom / pan. The mouse path
is left untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
MyrkoF added a commit to MyrkoF/droneroute that referenced this pull request Jul 30, 2026
Le merge git de feat/touch-template-drawing (basée sur main SANS orbit-z) dans
dataterra-build etait textuellement propre mais semantiquement incomplet :
onTouchEnd ne connaissait pas le template orbitz -> dessin Orbit+Z muet au
tactile. Bloc orbitz copie de onMouseUp (identique au port dataterra 8ed4699).
Ce commit n'existe QUE dans dataterra-build ; il disparaitra quand la PR fcsonline#64
sera rebasee sur un main contenant orbit-z (PR fcsonline#63).
@MyrkoF

MyrkoF commented Sep 2, 2026

Copy link
Copy Markdown
Author

Closing: we'll keep maintaining these changes in our fork (MyrkoF/droneroute, branch dataterra-build) rather than upstream. Thanks for DroneRoute — feel free to cherry-pick anything useful.

@MyrkoF MyrkoF closed this Sep 2, 2026
@MyrkoF
MyrkoF deleted the feat/touch-template-drawing branch September 2, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant