Private
_currentPrivate
_currentPrivate
_disposedPrivate
_dropPrivate
_overridePrivate
_promisePrivate
_resolvePrivate
_scrollReadonly
documentThe target document for dragging events.
Readonly
dragThe drag image element for the drag object.
Readonly
mimeThe mime data for the drag object.
Readonly
proposedThe proposed drop action for the drag object.
Readonly
sourceGet the drag source for the drag object.
Readonly
supportedThe supported drop actions for the drag object.
Test whether the drag object is disposed.
Private
_addPrivate
_attachPrivate
_detachPrivate
_evtHandle the 'keydown'
event for the drag object.
Private
_evtHandle the 'pointermove'
event for the drag object.
Private
_evtHandle the 'pointerup'
event for the drag object.
Private
_finalizeFinalize the drag operation and resolve the drag promise.
Private
_onPrivate
_removePrivate
_setSet the internal drop action state and update the drag cursor.
Private
_updateUpdate the current target node using the given mouse event.
Private
_updateUpdate the drag scroll element under the mouse.
Dispose of the resources held by the drag object.
This will cancel the drag operation if it is active.
Protected
moveStart the drag operation at the specified client position.
The client X position for the drag start.
The client Y position for the drag start.
A promise which resolves to the result of the drag.
If the drag has already been started, the promise created by the
first call to start
is returned.
If the drag operation has ended, or if the drag object has been
disposed, the returned promise will resolve to 'none'
.
The drag object will be automatically disposed when drag operation
completes. This means Drag
objects are for single-use only.
This method assumes the left mouse button is already held down.
An object which manages a drag-drop operation.
A drag object dispatches four different events to drop targets:
'lm-dragenter'
- Dispatched when the mouse enters the target element. This event must be canceled in order to receive any of the other events.'lm-dragover'
- Dispatched when the mouse moves over the drop target. It must cancel the event and set thedropAction
to one of the supported actions in order to receive drop events.'lm-dragleave'
- Dispatched when the mouse leaves the target element. This includes moving the mouse into child elements.'lm-drop'
- Dispatched when the mouse is released over the target element when the target indicates an appropriate drop action. If the event is canceled, the indicated drop action is returned to the initiator through the resolved promise.A drag operation can be terminated at any time by pressing
Escape
or by disposing the drag object.A drag object has the ability to automatically scroll a scrollable element when the mouse is hovered near one of its edges. To enable this, add the
data-lm-dragscroll
attribute to any element which the drag object should consider for scrolling.Notes
This class is designed to be used when dragging and dropping custom data within a single application. It is not a replacement for the native drag-drop API. Instead, it provides an API which allows drag operations to be initiated programmatically and enables the transfer of arbitrary non-string objects; features which are not possible with the native drag-drop API.