Primitives / foldkit-primitives/interaction

Move

namespace · packages/primitives/src/interaction/move.ts:7

export * as Move from './move.js'

Move as a Behavior: attaches the foldkit-primitives/dom Mount to a draggable slot and maps its facts into the view's Messages. No Bundle: a drag's meaning (a threshold, a snap, a reorder) is the parent's update, and the deltas are already facts.

In the guides

Members

Move.behavior

function · packages/primitives/src/interaction/move.ts:19

function behavior<Slots>(
  slots: Slots,
): <Input, ParentMessage>(
  options: BehaviorOptions<Slots, ParentMessage>,
) => Behavior.NamedBehavior<Slots, Input, ParentMessage>

Move.BehaviorOptions

interface · packages/primitives/src/interaction/move.ts:13

interface BehaviorOptions<Slots, ParentMessage> {
  readonly handle: keyof Slots & string
  readonly toMessage: (fact: Fact) => ParentMessage
}

Move.Fact

type · packages/primitives/src/dom/move.ts:26

type Fact = MoveStarted | Moved | MoveEnded

Move.mount

const · packages/primitives/src/dom/move.ts:48

const mount: Mount.MountDefinitionNoArgs<
  'Move',
  | {
      readonly _tag: 'MoveStarted'
      readonly pointerId: number
      readonly pointerType: string
    }
  | {
      readonly _tag: 'Moved'
      readonly pointerId: number
      readonly deltaX: number
      readonly deltaY: number
      readonly pointerType: string
    }
  | {
      readonly _tag: 'MoveEnded'
      readonly pointerId: number
      readonly completed: boolean
    }
>

Pointer movement on an element as a Mount: a primary-button pointer down captures the pointer, each move reports the delta from where it started, and up, cancel, or lost capture ends it. Nothing is decided here: a drag threshold, a snap, or a constraint is the parent's update. Capture is released with the Mount.

Move.Moved

const · packages/primitives/src/dom/move.ts:10

const Moved: Schema.TaggedStruct<
  'Moved',
  {
    readonly pointerId: Schema.Number
    readonly deltaX: Schema.Number
    readonly deltaY: Schema.Number
    readonly pointerType: Schema.String
  }
>

Move.MoveEnded

const · packages/primitives/src/dom/move.ts:19

const MoveEnded: Schema.TaggedStruct<
  'MoveEnded',
  { readonly pointerId: Schema.Number; readonly completed: Schema.Boolean }
>

Move.MoveStarted

const · packages/primitives/src/dom/move.ts:4

const MoveStarted: Schema.TaggedStruct<
  'MoveStarted',
  { readonly pointerId: Schema.Number; readonly pointerType: Schema.String }
>