@eclipse-scout/core
Version:
Eclipse Scout runtime
136 lines • 4.8 kB
TypeScript
/// <reference types="jquery" />
import { Event, EventEmitter, EventMap, Insets, Point, Rectangle, Session, Widget } from '../index';
export declare class MoveSupport<TElem extends Widget> extends EventEmitter {
self: MoveSupport<TElem>;
eventMap: MoveSupportEventMap;
/**
* Minimal distance in pixels for a "mouse move" action to take effect.
* Prevents "mini jumps" when simply clicking on an element.
*/
mouseMoveThreshold: number;
/**
* The maximum size the clone should have. If it exceeds that size it will be scaled down.
*/
maxCloneSize: number;
/**
* Widget containing the draggable elements
*/
widget: Widget;
protected _moveData: MoveData<TElem>;
protected _animationDurationFactor: number;
protected _mouseMoveHandler: (event: JQuery.MouseMoveEvent) => void;
protected _mouseUpHandler: (event: JQuery.MouseUpEvent) => void;
protected _keyDownHandler: (event: KeyboardEvent) => void;
protected _releasingScrollHandler: (event: JQuery.ScrollEvent) => void;
/**
* @param widget the widget containing the draggable elements. Is used to automatically cancel the move operation when the widget is removed.
*/
constructor(widget: Widget);
/**
* @return `true` if the dragging was started successfully, falsy otherwise.
*/
start(event: JQuery.MouseDownEvent, elements: TElem[], draggedElement: TElem): boolean;
protected _initMoveData(event: JQuery.MouseDownEvent, elements: TElem[], draggedElement: TElem): void;
protected _createElementInfos(elements: TElem[], draggedElement: TElem): DraggableElementInfo<TElem>[];
protected _updateElementInfo(elementInfo: DraggableElementInfo<TElem>): void;
protected _updateElementInfos(): void;
cancel(): void;
protected _restoreStyles(): void;
protected _onMouseMove(event: JQuery.MouseMoveEvent): void;
protected _calculateScale(): number;
/**
* Adjusts relative values if the panel has been scrolled while dragging (e.g. using the mouse wheel)
*/
protected _updateOffsets(): void;
protected _drag(event: JQuery.MouseMoveEvent): void;
protected _onFirstMouseMove(): void;
protected _append$Clone(): void;
protected _onMouseUp(event: JQuery.MouseUpEvent): void;
protected _onKeyDown(event: KeyboardEvent): void;
protected _cleanup(): void;
protected _moveToTarget(targetBounds: Rectangle): JQuery.Promise<void>;
protected _onReleasingScroll(event: JQuery.ScrollEvent): void;
/**
* @returns the target offset bounds to where the element should be moved
*/
protected _dragEnd(event: JQuery.MouseUpEvent): JQuery.Promise<Rectangle>;
protected _moveEnd(): void;
protected _end(): void;
protected _cancel(): void;
}
/**
* Temporary data structure to store data while mouse actions are handled.
*/
export interface MoveData<TElem extends Widget> {
/**
* Distance from cursor to the edges of the dragged element.
*/
cursorDistance: Insets;
session: Session;
$window: JQuery<Window>;
/**
* The container containing the draggable elements
*/
$container: JQuery;
/**
* The offset bounds of the container;
*/
containerBounds: Rectangle;
/**
* The draggable elements.
*/
elements: TElem[];
/**
* Contains various information about each element.
*/
elementInfos: DraggableElementInfo<TElem>[];
/**
* Contains various information about the dragged element.
*/
draggedElementInfo: DraggableElementInfo<TElem>;
/**
* Points to draggedElementInfo.$element.
*/
$draggedElement: JQuery;
/**
* The position of the cursor when the dragging started.
*/
startCursorPosition: Point;
/**
* The current position of the cursor.
*/
currentCursorPosition: Point;
/**
* Whether an element is being moved.
*/
moving: boolean;
/**
* A clone of the dragged element that follows the cursor. The dragged element itself stays at its original position until it should be moved to a new location.
*/
$clone: JQuery;
/**
* A dedicated shadow element so it can be animated.
*/
$cloneShadow: JQuery;
cloneStartOffset: Point;
cloneBounds: Rectangle;
}
export interface DraggableElementInfo<TElem extends Widget> {
element: TElem;
$element: JQuery;
/**
* The relative position to the container.
*/
position: Point;
/**
* The size and absolute position (relative to the window).
*/
bounds: Rectangle;
}
export interface MoveSupportEventMap extends EventMap {
'drag': Event;
'moveEnd': Event;
'end': Event;
'cancel': Event;
}
//# sourceMappingURL=MoveSupport.d.ts.map