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.
T = void
(position, arg) => PointerPositionHandlers | undefined
Callback function invoked when the pointerdown event happens.
Directive<T>
The pointerdownPositionDirective that can be applied to elements.
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`);
}
};
}); Configuration options for tracking pointer position after a pointerdown event.
optionalonEnd: (event?) =>void
Callback function invoked when the move ends after a pointerdown event.
void
optionalonMove: (event) =>void
Callback function invoked when the mouse moves after a pointerdown event.
void