Primitives / foldkit-primitives/dom
PointerDrag
const · packages/primitives/src/dom/pointer-drag.ts:133
const PointerDrag: Mount.MountDefinitionWithArgs<
'PointerDrag',
{
attribute: Schema.String
targets: Schema.optionalKey<
Schema.$Array<
Schema.Struct<{
readonly attribute: Schema.String
readonly within: Schema.String
}>
>
>
part: Schema.optionalKey<Schema.String>
gaps: Schema.optionalKey<Schema.Boolean>
edgeScroll: Schema.optionalKey<
Schema.Struct<{
readonly edge: Schema.optionalKey<Schema.Number>
readonly speed: Schema.optionalKey<Schema.Number>
}>
>
},
| { readonly _tag: 'DragStarted'; readonly id: string }
| {
readonly _tag: 'DraggedOver'
readonly over: {
readonly id: string
readonly zone: 'after' | 'before' | 'inside'
readonly part?: string
} | null
readonly region?: boolean
}
| {
readonly _tag: 'DragDropped'
readonly id: string
readonly over: {
readonly id: string
readonly zone: 'after' | 'before' | 'inside'
readonly part?: string
} | null
readonly region?: boolean
}
| { readonly _tag: 'DragCancelled'; readonly id: string }
>Dragging one marked descendant of an element onto another, as a Mount. A
descendant is marked by an attribute whose value is its id, as Targets
marks them; a press on one that then moves past a threshold starts a drag (a
finger's, held still for HOLD_TO_DRAG_MS, as a touch that moves first scrolls), and
the pointer's place over another marked descendant is reported with the
zone of it the pointer is in: its first third (before), its middle
(inside), or its last third (after). Releasing drops, and Escape or a
cancelled pointer ends the drag with nothing dropped.
It writes no roles, no tabindex and no key handling, so the marked
elements can be anything: a tree's rows, a canvas's nodes. The keyboard's way
to do what a drag does is the parent's to give. Geometry is measured when the
pointer moves and never kept; what a drop means is the parent's update.