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
@@ -3,8 +3,16 @@ import { Download, RefreshCw, Save, Upload } from 'lucide-react';
|
||||
import { api, isVersionConflict } from './lib/api';
|
||||
import { MapCanvas } from './components/MapCanvas';
|
||||
import { ParameterPanel, type ParameterPanelHandle } from './components/ParameterPanel';
|
||||
import { elementSelectionFor, type ElementSelection } from './edit/element';
|
||||
import {
|
||||
crosswalkHandleFor,
|
||||
elementSelectionFor,
|
||||
groupMembers,
|
||||
orientedBoundsOf,
|
||||
type ElementSelection,
|
||||
} from './edit/element';
|
||||
import { directEditEnabled, intervalEditingSupported } from './edit/flag';
|
||||
import type { ElementOutline } from './edit/handle-layer';
|
||||
import { rendersSame } from './edit/parameter';
|
||||
import { PreviewRequester, type PreviewDraft } from './edit/preview-request';
|
||||
import { anchorSnapshotFor, constraintValueFor, draftConstraint, operationFor } from './edit/projection';
|
||||
import { disabledReasonOf, handlesForSegment, intervalRangeHandles, type IntervalRangeHandle } from './edit/selection';
|
||||
@@ -169,6 +177,20 @@ function App() {
|
||||
* element box and its controls hang off this.
|
||||
*/
|
||||
const [element, setElement] = useState<ElementSelection | null>(null);
|
||||
/**
|
||||
* The selected element as something to draw and grab.
|
||||
*
|
||||
* The box carries the id of the control that moves it rather than an id of its
|
||||
* own, so grabbing the zebra runs the same gesture as grabbing that control's
|
||||
* dot — no second drag path, no second constraint.
|
||||
*/
|
||||
const elementOutline = useMemo<ElementOutline | null>(() => {
|
||||
if (!directEditEnabled || !element || !state) return null;
|
||||
const handle = crosswalkHandleFor(element, state.compiled.model.roads, editHandles);
|
||||
if (!handle?.editable) return null;
|
||||
const bounds = orientedBoundsOf(groupMembers(state.layers.crosswalks?.features ?? [], element.elementId));
|
||||
return bounds ? { handleId: handle.handleId, bounds } : null;
|
||||
}, [element, editHandles, state]);
|
||||
const sessionRef = useRef<EditSession | null>(null);
|
||||
if (directEditEnabled && !sessionRef.current) sessionRef.current = new EditSession();
|
||||
// Per-frame drag feedback reaches the panel through this rather than through
|
||||
@@ -301,6 +323,14 @@ function App() {
|
||||
};
|
||||
/** A settled value from either channel: one undoable command, or nothing. */
|
||||
const settleValue = (handle: EditHandle, value: number) => {
|
||||
// A gesture that did not move the value must not become an edit. `handle` was
|
||||
// captured at pointerdown, so this compares against the pre-drag value. The
|
||||
// element box is a large hit target, which makes a click-without-drag common
|
||||
// rather than an edge case — but the same applies to a tapped handle dot.
|
||||
if (rendersSame(value, handle.value.current)) {
|
||||
abandonGesture();
|
||||
return;
|
||||
}
|
||||
const draft = draftFor(handle, value);
|
||||
if (draft) commitGesture(draft, [`constraint:${handle.handleId}`]);
|
||||
else abandonGesture();
|
||||
@@ -570,6 +600,7 @@ function App() {
|
||||
onBackground={() => setElement(null)}
|
||||
handles={editHandles}
|
||||
ranges={editRanges}
|
||||
element={elementOutline}
|
||||
preview={preview}
|
||||
ghostPending={session?.degraded ?? false}
|
||||
onHandleDrag={(handle, value) => {
|
||||
|
||||
Reference in new issue
Block a user