dragStart method

  1. @override
void dragStart(
  1. Element draggable,
  2. Point<num> startPosition
)
override

Called when the drag operation starts.

This method must set the avatar variable and must attache it to the DOM.

The provided draggable is used to know where in the DOM the drag avatar can be inserted.

The startPosition is the position where the drag started, relative to the whole document (page coordinates).

Implementation

@override
void dragStart(Element draggable, Point startPosition) {
  // Use the draggable itself as avatar.
  avatar = draggable;

  // Ensure avatar has an absolute position.
  if (avatar != null) {
    avatar!.style.position = 'absolute';
  }

  // Get the start offset of the draggable (relative to the closest positioned
  // ancestor).
  _draggableStartOffset = draggable.offset.topLeft;

  // Set the initial position of the original.
  setLeftTop(_draggableStartOffset!);
}