import { type Point2d } from '../../mod.ts'; import { DnDEvent } from './events.ts'; import type { DragAndDropObserverContext, DragAndDropObserverOptions, DragAndDropPluginManager, DragAndDropState } from './types.ts'; /** * Drag-and-drop behavior observer. * Allows to implement drag-and-drop by providing event handlers. * Don't affects element' style or any other properties, just listens some events. * @internal */ export declare class DragAndDropObserver { protected readonly options: DragAndDropObserverOptions; protected state: DragAndDropState; protected plugins: DragAndDropPluginManager; protected sharedEvent?: DnDEvent; protected observation?: { readonly element: HTMLElement; readonly unobserve: VoidFunction; }; constructor(options?: DragAndDropObserverOptions); /** * Connects instance to given element. * An observer can only observe one element at a time. * @param element Element. * @returns Unobserve function. * @throws When trying to observe second element. */ observe(element: HTMLElement): VoidFunction; /** * Handles `pointerdown` event. * @param event Pointer event. * @param ctx Context. */ protected handlePointerDown(event: PointerEvent, ctx: DragAndDropObserverContext): void; /** * Handles `pointermove` event. * @param event Pointer event. * @param ctx Context. */ protected handlePointerMove(event: PointerEvent, ctx: DragAndDropObserverContext): void; /** * Handles `pointerup` and `pointercancel` events. * @param event Pointer event. * @param ctx Context. */ protected handlePointerRelease(event: PointerEvent, ctx: DragAndDropObserverContext): void; /** * Dispatches `grab` event. * @param element Element. * @param nativeEvent Native event. * @param clientPosition Client position from event. */ protected dispatchGrab(element: HTMLElement, nativeEvent: PointerEvent, clientPosition: Point2d): void; /** * Returns DnDEvent from payload. * @param target Element. * @param state State. * @param nativeEvent Native event. * @param clientPosition Client position. * @returns Event. */ protected getEvent(target: HTMLElement, state: DragAndDropState, nativeEvent: E, clientPosition: Point2d): DnDEvent; }