@progress/kendo-draggable-common
Version:
Kendo UI TypeScript package starter template
188 lines (187 loc) • 5.41 kB
TypeScript
/** @hidden */
export interface DragAndDropState {
drag: DragTarget | null;
drop: DropTarget | null;
drags: DragTarget[];
drops: DropTarget[];
pressed: boolean;
ignoreMouse: boolean;
autoScroll: boolean;
isScrolling: boolean;
scrollableParent?: HTMLElement | null;
autoScrollDirection?: {
horizontal: boolean;
vertical: boolean;
};
initialClientOffset: {
x: number;
y: number;
};
clientOffset: {
x: number;
y: number;
};
initialScrollOffset: {
x: number;
y: number;
};
scrollOffset: {
x: number;
y: number;
};
offset: {
x: number;
y: number;
};
pageOffset: {
x: number;
y: number;
};
velocity: {
x: number;
y: number;
};
}
/** @hidden */
export declare enum DRAG_AND_DROP_DISPATCH_ACTION {
POINTER_DOWN = "pointerdown",
POINTER_MOVE = "pointermove",
POINTER_UP = "pointerup",
POINTER_CANCEL = "pointercancel",
MOUSE_DOWN = "mousedown",
MOUSE_MOVE = "mousemove",
MOUSE_UP = "mouseup",
CONTEXT_MENU = "contextmenu",
TOUCH_START = "touchstart",
TOUCH_MOVE = "touchmove",
TOUCH_END = "touchend",
TOUCH_CANCEL = "touchcancel",
SCROLL = "scroll",
START = "KENDO_DRAG_AND_DROP_START",
MOVE = "KENDO_DRAG_AND_DROP_MOVE",
END = "KENDO_DRAG_AND_DROP_END",
CANCEL = "KENDO_DRAG_AND_DROP_CANCEL"
}
/**
* Represents a unified drag event that is triggered regardless if the native event underneath is a pointer, mouse, touch, or scroll event.
*/
export interface NormalizedDragEvent {
/**
* Represents the horizontal coordinate within the viewport
*/
clientX: number;
/**
* Represents the vertical coordinate within the viewport
*/
clientY: number;
/**
* Represents the horizontal coordinate at which the mouse was clicked, relative to the left edge of the entire document.
*/
pageX: number;
/**
* Represents the vertical coordinate at which the mouse was clicked, relative to the left edge of the entire document.
*/
pageY: number;
/**
* Represents the number of pixels that the document is currently scrolled horizontally.
*/
scrollX: number;
/**
* Represents the number of pixels that the document is currently scrolled vertically.
*/
scrollY: number;
/**
* Represents the horizontal offset coordinate of the mouse pointer between that event and the padding edge of the target node.
*/
offsetX: number;
/**
* Represents the vertical offset coordinate of the mouse pointer between that event and the padding edge of the target node.
*/
offsetY: number;
/**
* Represents the event's type.
*/
type: string;
/**
* Indicates if the native event is a touch event.
*/
isTouch?: boolean;
/**
* Represents the original event which resulted in a drag event.
*/
originalEvent: PointerEvent | MouseEvent | TouchEvent | Event;
/**
* Indicates if the `control` key was pressed when the event occurred.
*/
ctrlKey: boolean;
/**
* Indicates if the `shift` key was pressed when the event occurred.
*/
shiftKey: boolean;
/**
* Indicates if the `alt` key was pressed when the event occurred.
*/
altKey: boolean;
/**
* Indicates if the `command` (on Mac) key was pressed when the event occurred.
*/
metaKey: boolean;
}
/** @hidden */
export declare const normalizeEvent: (event: Event | MouseEvent | PointerEvent | TouchEvent, state: DragAndDropState) => NormalizedDragEvent;
/** @hidden */
export interface DragTarget {
element: HTMLElement | null;
hint?: HTMLElement | null;
onPress?: (event: NormalizedDragEvent) => void;
onRelease?: (event: NormalizedDragEvent) => void;
onDragStart?: (event: NormalizedDragEvent) => void;
onDrag?: (event: NormalizedDragEvent) => void;
onDragEnd?: (event: NormalizedDragEvent) => void;
}
/** @hidden */
export interface DropTarget {
element: HTMLElement | null;
onDragEnter?: (event: NormalizedDragEvent) => void;
onDragOver?: (event: NormalizedDragEvent) => void;
onDragLeave?: (event: NormalizedDragEvent) => void;
onDrop?: (event: NormalizedDragEvent) => void;
}
/** @hidden */
export declare type DragAndDropAction = {
event: PointerEvent | MouseEvent | TouchEvent | Event;
payload: DragTarget;
};
/** @hidden */
export declare const dispatchDragAndDrop: (state: DragAndDropState, action: DragAndDropAction, callbacks?: {
onIsScrollingChange?: (value: boolean) => void;
onIsPressedChange?: (value: boolean) => void;
onVelocityChange?: (value: {
x: number;
y: number;
}) => void;
onOffsetChange?: (value: {
x: number;
y: number;
}) => void;
onPageOffsetChange?: (value: {
x: number;
y: number;
}) => void;
onClientOffsetChange?: (value: {
x: number;
y: number;
}) => void;
onInitialClientOffsetChange?: (value: {
x: number;
y: number;
}) => void;
onScrollOffsetChange?: (value: {
x: number;
y: number;
}) => void;
onInitialScrollOffsetChange?: (value: {
x: number;
y: number;
}) => void;
}) => void;