import Async, { CustomSignalClass, Signal } from "typescene-async"; /** Specialized custom event used by Drag to keep track of the operation */ export interface CustomDragEvent extends CustomEvent { /** Detail object provided to Drag.start to initiate drag operation */ detail: any; } /** Represents a drag operation (created by static .start(...) method) */ export declare class Drag extends Async.ObservableObject { /** Current drag operation, if any (use while handling drag events, e.g. get/set .detail with custom data, or observe coordinates) */ static current: Drag | null; /** Start tracking mouse movement after given mousedown event, sets and returns Drag.current to new instance of Drag with given detail object; Drop targets may listen for drag events (over/out/drop), and use information from the detail object to respond */ static start(mousedownEvent: { target: EventTarget | HTMLElement; clientX: number; clientY: number; }, detail?: any): Drag; /** Initialize the operation and start tracking mouse movement, sends drag start event to given target DOM element; starts sending drag over and drag out events as well */ private constructor(target, x, y, detail?); /** Application-defined data for this operation (observable), to be set by drag start event handler */ detail: any; /** Current screen X coordinate (read-only observable, constrained) */ readonly x: number; /** Current screen Y coordinate (read-only observable, constrained) */ readonly y: number; /** Promise for drop target HTML element, created when dragging, resolved after dropping, rejected when drag operation is cancelled. */ dropTarget: Async.Promise; /** Resolves to true when mouse actually moves, useful e.g. for calling pickUp */ moved: Async.Promise; /** Signal emitted when the drag operation completes successfully */ readonly Drop: CustomSignalClass<{}, Signal<{}>>; /** Signal emitted when the drag operation is cancelled */ readonly Cancel: CustomSignalClass<{}, Signal<{}>>; /** Constrain effective drag coordinates on (original) X and/or Y axis, and/or contrain to stay within given element on screen (calling this method twice does not constrain further, but the constraints are replaced) */ constrain(constrainX?: boolean, constrainY?: boolean, element?: HTMLElement): void; /** Make given element follow the mouse cursor while dragging; the element needs to be positioned absolute or fixed */ pickUp(element: HTMLElement, removeWhenDone?: boolean): void; /** Stop the current drag operation */ cancel(): void; /** Accept the current drop target (i.e. perform the drop, primarily called automatically by mouseup handler but can be called manually); sends drop event to drop target element */ drop(): void; /** Update mouse cursor screen coordinates (primarily called by mousemove handler); returns true if an element was scrolled - meaning update should be called again after a short time */ update(x: number, y: number): boolean; private _x; private _y; private _origTarget; private _currentTarget; private _moved_resolve; private _dropTarget_resolve; private _dropTarget_reject; private _getTarget; private _setCoords; } export default Drag;