Preview and placeholder
During a drag the original element is hidden. Two elements take its place:
- the preview, which follows the pointer
- the placeholder, an empty slot that marks where the item will land
Default preview
<vdnd-drag-preview /> clones the dragged element, copies its computed styles and sizes the clone to match the original. The point where the user grabbed the item stays under the pointer.
The clone is a picture of the item: its controls are disabled and out of the tab order. It keeps the item's id attributes, so rules that style the item through an ID style the clone too. That means the document has each of those IDs twice during a drag; see Known limitations.
The clone is made in the frame the item lifts, and copying the styles takes longer the more elements the row has. For rows with many elements on low-end devices, a custom preview is cheaper: with a template, drags skip the clone.
Custom preview
Pass a template to render your own preview instead of a clone:
The template context:
Set [vdndDraggableData]="task" on the draggable so the template receives the item.
<body>
The preview is moved into a div.vdnd-overlay-container at the end of <body>. This escapes ancestor transform, filter and perspective styles, which would otherwise break position: fixed (Ionic's ion-page is one example). Your component's styles still apply to elements in the preview template. But selectors that depend on ancestors, such as .board .card, no longer match. Style the preview by its own classes.
The preview box is inert and aria-hidden="true", with a default or a custom preview alike: nothing in it takes focus or reaches screen readers. Announce the drag yourself (see Accessibility), not with live content in the preview template.
cursorOffset (default { x: 8, y: 8 }) is only a fallback for when the grab point is unknown. Drags started by the library always know it.
Placeholder
Lists render the placeholder at the drop position, sized to the dragged item. It is an empty element with the classes vdnd-drag-placeholder and vdnd-drag-placeholder-visible. Style it globally:
<vdnd-placeholder> (PlaceholderComponent) is a separate indicator that accepts a custom template and that you render yourself. The built-in lists do not use it.