Primitives / foldkit-primitives/dom

Marquee

const · packages/primitives/src/dom/marquee.ts:73

const Marquee: Mount.MountDefinitionWithArgs<
  'Marquee',
  {
    attribute: Schema.String
    edgeScroll: Schema.optionalKey<
      Schema.Struct<{
        readonly edge: Schema.optionalKey<Schema.Number>
        readonly speed: Schema.optionalKey<Schema.Number>
      }>
    >
  },
  | { readonly _tag: 'MarqueeStarted'; readonly additive: boolean }
  | {
      readonly _tag: 'MarqueeChanged'
      readonly rect: {
        readonly x: number
        readonly y: number
        readonly width: number
        readonly height: number
      }
      readonly ids: readonly string[]
      readonly additive: boolean
    }
  | {
      readonly _tag: 'MarqueeEnded'
      readonly rect: {
        readonly x: number
        readonly y: number
        readonly width: number
        readonly height: number
      }
      readonly ids: readonly string[]
      readonly additive: boolean
    }
  | { readonly _tag: 'MarqueeCancelled' }
>

A lasso over an element's marked descendants, as a Mount. A press on empty space (anywhere in the element that is no marked descendant, no control and no scrollbar) that moves past DRAG_THRESHOLD starts a marquee; the rectangle from the press to the pointer, in the element's content coordinates, and the ids of the marked descendants it touches, are reported as the pointer moves. Releasing ends it, and Escape or a cancelled pointer cancels it. A touch never starts one: a finger on empty space scrolls.

It draws nothing and selects nothing: the rectangle is for the view to draw in a Slot of its own, and the ids are for the parent's update to select (Selection's Replaced). A press on a marked descendant is not its business, so it composes with PointerDrag on the same element. The pointer's own geometry is measured as it moves and never kept.