dragStart method
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) {
// Clone the draggable to create the avatar.
avatar = (draggable.clone(true) as Element)
..attributes.remove('id')
..style.cursor = 'inherit';
// Ensure avatar has an absolute position.
avatar!.style.position = 'absolute';
avatar!.style.zIndex = '100';
// Add the drag avatar to the parent element.
draggable.parentNode!.append(avatar!);
// Set the initial position of avatar (relative to the closest positioned
// ancestor).
setLeftTop(draggable.offset.topLeft);
}