feat: drag the crosswalk itself, not a dot beside it
A dashed box now hugs the selected group and is the thing you grab. It is oriented along the crossing rather than along latitude and longitude: measured groups run at azimuths from 14 to 105 degrees, so an axis-aligned box would sit visibly askew and read as a bug. Extents come out at 3.00m by 4.94m on every group, matching the compiler's literals. The box carries the handleId of the control that moves it rather than an id of its own, so grabbing it runs the existing value gesture — no second drag branch, no second constraint, and the dot still works where the two overlap. Resolving that control needs more than the segment: 15 of 23 segments carry two crosswalk-inset handles, one per junction, and one segment carries two groups. The junction is the road's last source node, which is the rule crossingJunctionInset() already applies rather than a guess, and it resolves 8/8 groups uniquely — the two-group segment included, told apart by direction. Also stops a gesture that never moved from becoming an edit. handleUpEvent always reports a final value, so a tap committed a constraint equal to the one already there. The box is a large target, which turns that from a curiosity into something a user would hit routinely. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
2694cad619
commit
7b5bb753a7
5 files changed
+309
-7
No files matched your search
@@ -8,7 +8,7 @@ import { createLayers, updateLayers, updateSelectedRoad, type LayerName } from '
|
||||
import { directEditEnabled } from '../edit/flag';
|
||||
import { createHandleDragInteraction } from '../edit/drag-interaction';
|
||||
import { EditGhostLayer } from '../edit/ghost-layer';
|
||||
import { EditHandleLayer } from '../edit/handle-layer';
|
||||
import { EditHandleLayer, type ElementOutline } from '../edit/handle-layer';
|
||||
import { EditPreviewLayer } from '../edit/preview-layer';
|
||||
import type { IntervalRangeHandle } from '../edit/selection';
|
||||
import type { EditHandle, PreviewLayerName, RoadIntervalAnchor } from '../edit/types';
|
||||
@@ -26,6 +26,8 @@ interface Props {
|
||||
handles?: EditHandle[];
|
||||
/** The two ends of the affected interval, drawn as squares. */
|
||||
ranges?: IntervalRangeHandle[];
|
||||
/** The selected element's box, grabbable as the control that moves it. */
|
||||
element?: ElementOutline | null;
|
||||
/** Authoritative preview geometry; null returns the map to the baseline. */
|
||||
preview?: Partial<Record<PreviewLayerName, GeoJson | null>> | null;
|
||||
/** Live value during a drag — the caller debounces the preview request. */
|
||||
@@ -49,6 +51,7 @@ export function MapCanvas({
|
||||
onBackground,
|
||||
handles,
|
||||
ranges,
|
||||
element,
|
||||
preview,
|
||||
onHandleDrag,
|
||||
onHandleDragEnd,
|
||||
@@ -179,8 +182,8 @@ export function MapCanvas({
|
||||
useEffect(() => {
|
||||
// Null when the flag is off, so this whole path is inert on main.
|
||||
// Only the editHandles source is replaced; baseline layers are never touched.
|
||||
handleLayerRef.current?.render(handles ?? [], ranges ?? []);
|
||||
}, [handles, ranges]);
|
||||
handleLayerRef.current?.render(handles ?? [], ranges ?? [], element ?? null);
|
||||
}, [handles, ranges, element]);
|
||||
useEffect(() => {
|
||||
// A non-degraded answer means the pending ghost has been superseded by real
|
||||
// geometry. Clearing an empty ghost is a no-op, so this is safe mid-drag.
|
||||
|
||||
Reference in new issue
Block a user