@itwin/itwinui-react
Version:
A react component library for iTwinUI
14 lines (13 loc) • 778 B
TypeScript
import * as React from 'react';
/**
* Helper hook that handles elements drag logic.
* @param elementRef Element ref that is draggable.
* @param containerRect Bounding rectangle of container element that element can't go outside. If not passed window is used as a container.
* @returns
* `onPointerDown` - handler that is called when pointer is down and handles all the dragging logic.
* `transform` - current transform of the element, it is used to preserve drag position when element visibility is being toggled.
*/
export declare const useDragAndDrop: (elementRef: React.RefObject<HTMLElement | null>, containerRef?: React.RefObject<HTMLElement | null>, enabled?: boolean) => {
onPointerDown: (e: React.PointerEvent<HTMLElement>) => void;
transform: string;
};