DragAndDropOperation Class

A drag-and-drop operation (https://html.spec.whatwg.org/multipage/dnd.html#drag-and-drop-processing-model), driven by the user interactions of a host (e.g. the test driver of the web-platform-tests): DragAndDropOperation.TryStart when the pointer moves with a pressed button, DragAndDropOperation.Update each time it moves, and DragAndDropOperation.End when the button is released. The iterations of the processing model run on each move instead of every 350 ms.

public sealed class DragAndDropOperation

Remarks

As in the browsers, the element under the pointer (the immediate user selection) is the current target element whether or not its dragenter event is canceled: dragenter and dragleave are fired when the pointer enters and leaves elements, dragover is fired at the element under the pointer, and the drop is accepted when the dragover event is canceled (the specification instead makes the body element the current target element when the dragenter event is not canceled). A drop event that is not canceled keeps the current drag operation (the dropEffect of the dragend event), instead of resetting it to "none". There is no feedback (drag image) and the drop of files from outside the user agent is not supported.

Properties

NameDescription
IsEndedWhether the operation ended (the button was released, or the drag event was canceled).
SourceNodeThe source node: the dragged element, or the first Text node of the dragged selection.

Whether the operation ended (the button was released, or the drag event was canceled).

public bool IsEnded { get; }

Property value

bool

The source node: the dragged element, or the first Text node of the dragged selection.

public Node SourceNode { get; }

Property value

Node

Methods

NameDescription
End(DragPointerState, bool)The last iteration, when the user releases the button (or cancels the operation, e.g. with the Escape key).
TryStart(Node, DragPointerState, bool)The steps run when the user attempts to begin a drag operation on node (the node under the pointer when the button was pressed). Returns null when nothing is dragged or when the dragstart event is canceled.
Update(Element?, DragPointerState)An iteration of the drag-and-drop operation while the pointer is over immediateUserSelection.

End(DragPointerState, bool)

DragAndDropOperation.cs

The last iteration, when the user releases the button (or cancels the operation, e.g. with the Escape key).

public void End(DragPointerState pointerState, bool canceled = false)

Parameters

pointerState DragPointerState
canceled bool

TryStart(Node, DragPointerState, bool)

DragAndDropOperation.cs

The steps run when the user attempts to begin a drag operation on node (the node under the pointer when the button was pressed). Returns null when nothing is dragged or when the dragstart event is canceled.

public static DragAndDropOperation? TryStart(Node node, DragPointerState pointerState, bool dragSelection = true)

Parameters

node Node
pointerState DragPointerState
dragSelection bool
Whether the selection can be dragged: the press was in the selection (the selection that the moves of the pointer are making is not dragged).

Returns

DragAndDropOperation?

Update(Element?, DragPointerState)

DragAndDropOperation.cs

An iteration of the drag-and-drop operation while the pointer is over immediateUserSelection.

public void Update(Element? immediateUserSelection, DragPointerState pointerState)

Parameters

immediateUserSelection Element?
pointerState DragPointerState