import {DragDropModule} from '@angular/cdk/drag-drop';
DragDrop
Service that allows for drag-and-drop functionality to be attached to DOM elements.
createDrag | |
---|---|
Turns an element into a draggable item. |
|
Parameters | |
element HTMLElement | ElementRef<HTMLElement>
|
Element to which to attach the dragging functionality. |
config DragRefConfig = DEFAULT_CONFIG
|
Object used to configure the dragging behavior. |
Returns | |
DragRef<T>
|
|
createDropList | |
---|---|
Turns an element into a drop list. |
|
Parameters | |
element HTMLElement | ElementRef<HTMLElement>
|
Element to which to attach the drop list functionality. |
Returns | |
DropListRef<T>
|
|
CdkDropList
Container that wraps a set of draggable items.
Selector: [cdkDropList] cdk-drop-list
Exported as: cdkDropListName | Description |
---|---|
@Input('cdkDropListConnectedTo')
|
Other draggable containers that this container is connected to and into which the container's items can be transferred. Can either be references to other drop containers, or their unique IDs. |
@Input('cdkDropListData')
|
Arbitrary data to attach to this container. |
@Input('cdkDropListDisabled')
|
Whether starting a dragging sequence from this container is disabled. |
@Input('cdkDropListEnterPredicate')
|
Function that is used to determine whether an item is allowed to be moved into a drop container. |
@Input()
|
Unique ID for the drop zone. Can be used as a reference
in the |
@Input('cdkDropListLockAxis')
|
Locks the position of the draggable elements inside the container along the specified axis. |
@Input('cdkDropListOrientation')
|
Direction in which the list is oriented. |
@Output('cdkDropListDropped')
|
Emits when the user drops an item inside the container. |
@Output('cdkDropListEntered')
|
Emits when the user has moved a new drag item into this container. |
@Output('cdkDropListExited')
|
Emits when the user removes an item from the container by dragging it into another container. |
@Output('cdkDropListSorted')
|
Emits as the user is swapping items while actively dragging. |
|
Element that the drop list is attached to. |
drop | |
---|---|
Drops an item into this container. |
|
Parameters | |
item CdkDrag<any>
|
Item being dropped into the container. |
currentIndex number
|
Index at which the item should be inserted. |
previousContainer Partial<CdkDropListContainer<any>>
|
Container from which the item got dragged in. |
isPointerOverContainer boolean
|
Whether the user's pointer was over the container when the item was dropped. |
enter | |
---|---|
Emits an event to indicate that the user moved an item into the container. |
|
Parameters | |
item CdkDrag<any>
|
Item that was moved into the container. |
pointerX number
|
Position of the item along the X axis. |
pointerY number
|
Position of the item along the Y axis. |
exit | |
---|---|
Removes an item from the container after it was dragged into another container by the user. |
|
Parameters | |
item CdkDrag<any>
|
Item that was dragged out. |
getItemIndex | |
---|---|
Figures out the index of an item in the container. |
|
Parameters | |
item CdkDrag<any>
|
Item whose index should be determined. |
Returns | |
number
|
|
start | |
---|---|
Starts dragging an item. |
CdkDropListGroup
Declaratively connects sibling cdkDropList
instances together. All of the cdkDropList
elements that are placed inside a cdkDropListGroup
will be connected to each other
automatically. Can be used as an alternative to the cdkDropListConnectedTo
input
from cdkDropList
.
Selector: [cdkDropListGroup]
Exported as: cdkDropListGroupName | Description |
---|---|
@Input('cdkDropListGroupDisabled')
|
Whether starting a dragging sequence from inside this group is disabled. |
CdkDrag
Element that can be moved inside a CdkDropList container.
Selector: [cdkDrag]
Exported as: cdkDragName | Description |
---|---|
@Input('cdkDragBoundary')
|
Selector that will be used to determine the element to which the draggable's position will be constrained. Matching starts from the element's parent and goes up the DOM until a matching element has been found. |
@Input('cdkDragData')
|
Arbitrary data to attach to this drag instance. |
@Input('cdkDragDisabled')
|
Whether starting to drag this element is disabled. |
@Input('cdkDragLockAxis')
|
Locks the position of the dragged element along the specified axis. |
@Input('cdkDragRootElement')
|
Selector that will be used to determine the root draggable element, starting from
the |
@Output('cdkDragDropped')
|
Emits when the user drops the item inside a container. |
@Output('cdkDragEnded')
|
Emits when the user stops dragging an item in the container. |
@Output('cdkDragEntered')
|
Emits when the user has moved the item into a new container. |
@Output('cdkDragExited')
|
Emits when the user removes the item its container by dragging it into another container. |
@Output('cdkDragMoved')
|
Emits as the user is dragging the item. Use with caution, because this event will fire for every pixel that the user has dragged. |
@Output('cdkDragReleased')
|
Emits when the user has released a drag item, before any animations have started. |
@Output('cdkDragStarted')
|
Emits when the user starts dragging the item. |
|
Droppable container that the draggable is a part of. |
|
Element that the draggable is attached to. |
getPlaceholderElement | |
---|---|
Returns the element that is being used as a placeholder while the current element is being dragged. |
|
Returns | |
HTMLElement
|
|
getRootElement | |
---|---|
Returns the root draggable element. |
|
Returns | |
HTMLElement
|
|
reset | |
---|---|
Resets a standalone drag item to its initial position. |
CdkDragHandle
Handle that can be used to drag and CdkDrag instance.
Selector: [cdkDragHandle]
Name | Description |
---|---|
@Input('cdkDragHandleDisabled')
|
Whether starting to drag through this handle is disabled. |
|
CdkDragPreview
Element that will be used as a template for the preview of a CdkDrag when it is being dragged.
Selector: ng-template[cdkDragPreview]
Name | Description |
---|---|
@Input()
|
Context data to be added to the preview template instance. |
|
CdkDragPlaceholder
Element that will be used as a template for the placeholder of a CdkDrag when it is being dragged. The placeholder is displayed in place of the element being dragged.
Selector: ng-template[cdkDragPlaceholder]
Name | Description |
---|---|
@Input()
|
Context data to be added to the placeholder template instance. |
|
DragRefConfig
Object that can be used to configure the behavior of DragRef.
Name | Description |
---|---|
|
Minimum amount of pixels that the user should drag, before the CDK initiates a drag sequence. |
|
Amount the pixels the user should drag before the CDK considers them to have changed the drag direction. |
CdkDragConfig
CdkDropListContainer
Name | Description |
---|---|
|
|
|
Arbitrary data to attach to all events emitted by this container. |
|
Whether starting a dragging sequence from this container is disabled. |
|
DOM node that corresponds to the drop container. |
|
Unique ID for the drop zone. |
|
Locks the position of the draggable elements inside the container along the specified axis. |
|
Direction in which the list is oriented. |
_getSiblingContainerFromPosition | |
---|---|
Parameters | |
item CdkDrag<any>
|
|
x number
|
|
y number
|
|
Returns | |
CdkDropListContainer | null
|
|
_isOverContainer | |
---|---|
Parameters | |
x number
|
|
y number
|
|
Returns | |
boolean
|
|
_sortItem | |
---|---|
Parameters | |
item CdkDrag<any>
|
|
pointerX number
|
|
pointerY number
|
|
delta { x
|
|
drop | |
---|---|
Drops an item into this container. |
|
Parameters | |
item CdkDrag<any>
|
Item being dropped into the container. |
currentIndex number
|
Index at which the item should be inserted. |
previousContainer Partial<CdkDropListContainer<any>>
|
Container from which the item got dragged in. |
isPointerOverContainer boolean
|
Whether the user's pointer was over the container when the item was dropped. |
enter | |
---|---|
Emits an event to indicate that the user moved an item into the container. |
|
Parameters | |
item CdkDrag<any>
|
Item that was moved into the container. |
pointerX number
|
Position of the item along the X axis. |
pointerY number
|
Position of the item along the Y axis. |
exit | |
---|---|
Removes an item from the container after it was dragged into another container by the user. |
|
Parameters | |
item CdkDrag<any>
|
Item that was dragged out. |
getItemIndex | |
---|---|
Figures out the index of an item in the container. |
|
Parameters | |
item CdkDrag<any>
|
Item whose index should be determined. |
Returns | |
number
|
|
start | |
---|---|
Starts dragging an item. |
CdkDragStart
Event emitted when the user starts dragging a draggable.
Name | Description |
---|---|
|
Draggable that emitted the event. |
CdkDragRelease
Event emitted when the user releases an item, before any animations have started.
Name | Description |
---|---|
|
Draggable that emitted the event. |
CdkDragEnd
Event emitted when the user stops dragging a draggable.
Name | Description |
---|---|
|
Draggable that emitted the event. |
CdkDragEnter
Event emitted when the user moves an item into a new drop container.
Name | Description |
---|---|
|
Container into which the user has moved the item. |
|
Item that was removed from the container. |
CdkDragExit
Event emitted when the user removes an item from a drop container by moving it into another one.
Name | Description |
---|---|
|
Container from which the user has a removed an item. |
|
Item that was removed from the container. |
CdkDragDrop
Event emitted when the user drops a draggable item inside a drop container.
Name | Description |
---|---|
|
Container in which the item was dropped. |
|
Current index of the item. |
|
Whether the user's pointer was over the container when the item was dropped. |
|
Item that is being dropped. |
|
Container from which the item was picked up. Can be the same as the |
|
Index of the item when it was picked up. |
CdkDragMove
Event emitted as the user is dragging a draggable item.
Name | Description |
---|---|
|
Indicates the direction in which the user is dragging the element along each axis.
|
|
Native event that is causing the dragging. |
|
Position of the user's pointer on the page. |
|
Item that is being dragged. |
CdkDragSortEvent
Event emitted when the user swaps the position of two drag items.
Name | Description |
---|---|
|
Container that the item belongs to. |
|
Index that the item is currently in. |
|
Item that is being sorted. |
|
Index from which the item was sorted previously. |
moveItemInArray | |
---|---|
Moves an item one index in an array to another. |
|
Parameters | |
array T[]
|
Array in which to move the item. |
fromIndex number
|
Starting index of the item. |
toIndex number
|
Index to which the item should be moved. |
transferArrayItem | |
---|---|
Moves an item from one array to another. |
|
Parameters | |
currentArray T[]
|
Array from which to transfer the item. |
targetArray T[]
|
Array into which to put the item. |
currentIndex number
|
Index of the item in its current array. |
targetIndex number
|
Index at which to insert the item. |
copyArrayItem | |
---|---|
Copies an item from one array to another, leaving it in its original position in current array. |
|
Parameters | |
currentArray T[]
|
Array from which to copy the item. |
targetArray T[]
|
Array into which is copy the item. |
currentIndex number
|
Index of the item in its current array. |
targetIndex number
|
Index at which to insert the item. |
CDK_DROP_LIST
Injection token that is used to provide a CdkDropList instance to CdkDrag. Used for avoiding circular imports.
const CDK_DROP_LIST: InjectionToken<CdkDropListContainer<any>>;
CDK_DROP_LIST_CONTAINER
Injection token that is used to provide a CdkDropList instance to CdkDrag. Used for avoiding circular imports.
const CDK_DROP_LIST_CONTAINER: InjectionToken<CdkDropListContainer<any>>;
CDK_DRAG_CONFIG
Injection token that can be used to configure the behavior of CdkDrag
.
const CDK_DRAG_CONFIG: InjectionToken<DragRefConfig>;