For AI agents: the complete documentation index is available at https://gultyayev.github.io/ngx-virtual-dnd/llms.txt, the full documentation bundle is available at https://gultyayev.github.io/ngx-virtual-dnd/llms-full.txt, and this page is available as Markdown at https://gultyayev.github.io/ngx-virtual-dnd/api/components.md.

Components

All components are standalone and exported from ngx-virtual-dnd.

VirtualSortableListComponent

Selector: vdnd-sortable-list

Droppable, virtual scroller and placeholder in one element. The default choice. See the Quick start.

InputTypeDefaultDescription
droppableIdstringrequiredUnique ID of this list
itemsT[]requiredItems to render
itemHeightnumberrequiredRow height in px (the estimate when dynamicItemHeight is on)
itemIdFn(item: T) => stringrequiredReturns an item's ID; must equal the vdndDraggable value rendered for it
itemTemplateTemplateRef<VirtualScrollItemContext<T>>requiredRow template; its root element carries vdndDraggable
groupstring—Group name. Not needed inside a vdndGroup
containerHeightnumber—Height in px. Without it, give the inner vdnd-virtual-scroll a CSS height
dynamicItemHeightbooleanfalseMeasure rows instead of using a fixed height
trackByFn(index: number, item: T) => string | numberderived from itemIdFnTrack-by function for rendering
droppableDataunknown—Arbitrary data, delivered as DropEvent.destination.data
disabledbooleanfalseStop items being dropped into this list (items can still be dragged out; set disabled on the draggables too for a read-only list)
overscannumber3Rows rendered beyond the visible area, above and below
recycleRowsbooleanfalseReuse the views of rows that scroll out, see Row recycling.Added in 3.3.0
autoScrollEnabledbooleantrueScroll when dragging near the edges
autoScrollConfigPartial<AutoScrollConfig>{}Auto-scroll tuning, see Auto-scroll
constrainToContainerbooleanfalseKeep the preview and drop position inside the list
scrollInsetTopnumber0Height (px) of content overlaid on the top of the rows; they start below it. See Scroll insets
scrollInsetBottomnumber0Height (px) of content overlaid on the bottom of the rows; the last one scrolls clear of it
OutputTypeDescription
dropDropEventAn item was dropped into this list
placeholderMovePlaceholderMoveEventThe placeholder moved within this list (every row displacement).Added in 3.2.0

The item template context (VirtualScrollItemContext<T>) exposes $implicit (the item), index (position in the full list) and isSticky.

VirtualScrollContainerComponent

Selector: vdnd-virtual-scroll

Low-level virtual scroller. Place it inside an element with vdndDroppable. See Choosing a component.

InputTypeDefaultDescription
itemsT[]requiredItems to render
itemHeightnumberrequiredRow height in px
itemIdFn(item: T) => stringrequiredReturns an item's ID; must equal its vdndDraggable value
itemTemplateTemplateRef<VirtualScrollItemContext<T>>requiredRow template
droppableIdstring—ID of the enclosing vdndDroppable; needed to show the placeholder
containerHeightnumber—Height in px. Without it, give the element a CSS height
dynamicItemHeightbooleanfalseMeasure rows
trackByFn(index: number, item: T) => string | numberderived from itemIdFnTrack-by function
overscannumber3Extra rows rendered above and below
recycleRowsbooleanfalseReuse the views of rows that scroll out.Added in 3.3.0
stickyItemIdsstring[][]IDs of items that stay rendered at any scroll position
autoStickyDraggedItembooleantrueKeep the dragged item rendered while it is out of view
scrollContainerIdstring—ID used to register the container for auto-scroll
autoScrollEnabledbooleantrueScroll when dragging near the edges
autoScrollConfigPartial<AutoScrollConfig>{}Auto-scroll tuning
scrollInsetTopnumber0Height (px) of content overlaid on the top of the rows; they start below it
scrollInsetBottomnumber0Height (px) of content overlaid on the bottom of the rows; the last one scrolls clear of it
MethodSignatureDescription
scrollTo(position: number) => voidScroll to an absolute offset
scrollToIndex(index: number) => voidScroll to an item by index
scrollBy(delta: number) => voidScroll by a relative amount
getScrollTop() => numberCurrent scroll offset
getScrollHeight() => numberTotal scroll height

Get the instance with viewChild(VirtualScrollContainerComponent).

VirtualViewportComponent

Selector: vdnd-virtual-viewport

Self-scrolling container for *vdndVirtualFor. Positions all rows with one GPU-accelerated transform. Children inherit itemHeight and dynamicItemHeight. Needs a CSS height.

InputTypeDefaultDescription
itemHeightnumberrequiredRow height in px
dynamicItemHeightbooleanfalseMeasure rows
contentOffsetnumber0Space in px reserved above the rows
scrollContainerIdstring—ID used to register for auto-scroll
autoScrollEnabledbooleantrueScroll when dragging near the edges
autoScrollConfigPartial<AutoScrollConfig>{}Auto-scroll tuning
scrollInsetTopnumber0Height (px) of content pinned over the top edge; the rows start below it, or contentOffset down when that is more
scrollInsetBottomnumber0Height (px) of content pinned over the bottom edge; the last row scrolls clear of it

VirtualContentComponent

Selector: vdnd-virtual-content

Virtual rows inside an external scroll container, for page-level scrolling. Must be inside a vdndScrollable element. Projects an optional [vdndContentHeader] above the rows.

InputTypeDefaultDescription
itemHeightnumberrequiredRow height in px
dynamicItemHeightbooleanfalseMeasure rows
contentOffsetnumber0Offset above the rows; replaced by the measured vdndContentHeader height

DragPreviewComponent

Selector: vdnd-drag-preview

Renders the element that follows the pointer. Required: place it once. It moves itself into a body-level div.vdnd-overlay-container. The preview box is inert and aria-hidden="true". See Preview and placeholder.

InputTypeDefaultDescription
previewTemplateTemplateRef<DragPreviewContext<T>>—Custom preview; replaces the default clone
cursorOffset{ x: number; y: number }{ x: 8, y: 8 }Fallback offset, used only when the grab point is unknown

PlaceholderComponent

Selector: vdnd-placeholder

A drop-position indicator you render yourself. The built-in lists do not use it; they render DragPlaceholderComponent.

InputTypeDefaultDescription
heightnumber50Height in px
templateTemplateRef<PlaceholderContext>—Custom placeholder content

DragPlaceholderComponent

Selector: vdnd-drag-placeholder

The empty placeholder that the lists render at the drop position, sized to the dragged item. You rarely use it directly; style it through .vdnd-drag-placeholder.

InputTypeDefaultDescription
itemHeightnumberrequiredHeight in px