Bootstrap

API pointerdownPosition

createPointerdownPositionDirective

function

createPointerdownPositionDirective<T>(onStart): Directive<T>

Creates a directive for tracking pointer position during drag operations.

This function sets up event listeners that track pointer movements from an initial pointerdown event through pointermover and pointerup events. It provides a directive that can be attached to DOM elements to enable drag tracking functionality.

Type Parameters
T

T = void

Parameters
onStart

(position, arg) => PointerPositionHandlers | undefined

Callback function invoked when the pointerdown event happens.

Returns

Directive<T>

The pointerdownPositionDirective that can be applied to elements.

Example
const pointerPositionDirective = createPointerdownPositionDirective((event) => {
  console.log(`Drag started at (${event.clientX}, ${event.clientY})`);
  return {
    onMove: (event) => {
      console.log(`Dragging: ${event.clientX}, dy=${event.clientY}`);
    },
    onEnd: () => {
      console.log(`Drag ended`);
    }
  };
});

PointerPositionHandlers

interface

Configuration options for tracking pointer position after a pointerdown event.

Properties
onEnd()?

optional onEnd: (event?) => void

Callback function invoked when the move ends after a pointerdown event.

Parameters
event?

PointerEvent

Returns

void


onMove()?

optional onMove: (event) => void

Callback function invoked when the mouse moves after a pointerdown event.

Parameters
event

PointerEvent

Returns

void