DragRef
Reference to a draggable item. Used to manipulate or dispose of the item.
constructor
DragRef<T>lockAxis
"x" | "y"Axis along which dragging is locked.
dragStartDelay
number | { touch: number; mouse: number; }Amount of milliseconds to wait after the user has put their pointer down before starting to drag the element.
previewClass
string | string[] | undefinedClass to be added to the preview element.
scale
numberIf the parent of the dragged element has a scale transform, it can throw off the
positioning when the user starts dragging. Use this input to notify the CDK of the scale.
disabled
booleanWhether starting to drag this element is disabled.
disabled
booleanbeforeStarted
anyEmits as the drag sequence is being prepared.
started
anyEmits when the user starts dragging the item.
released
anyEmits when the user has released a drag item, before any animations have started.
ended
anyEmits when the user stops dragging an item in the container.
entered
anyEmits when the user has moved the item into a new container.
exited
anyEmits when the user removes the item its container by dragging it into another container.
dropped
anyEmits when the user drops the item inside a container.
moved
Observable<{ source: DragRef<any>; pointerPosition: { x: number; y: number; }; event: MouseEvent | TouchEvent; distance: Point; delta: { x: 0 | 1 | -1; y: 0 | 1 | -1; }; }>Emits as the user is dragging the item. Use with caution, because this event will fire for every pixel that the user has dragged.
data
TArbitrary data that can be attached to the drag item.
constrainPosition
DragConstrainPosition | undefinedFunction that can be used to customize the logic of how the position of the drag item is limited while it's being dragged. Gets called with a point containing the current position of the user's pointer on the page, a reference to the item being dragged and its dimensions. Should return a point describing where the item should be rendered.
getPlaceholderElement
HTMLElementReturns the element that is being used as a placeholder while the current element is being dragged.
HTMLElementgetRootElement
HTMLElementReturns the root draggable element.
HTMLElementgetVisibleElement
HTMLElementGets the currently-visible element that represents the drag item. While dragging this is the placeholder, otherwise it's the root element.
HTMLElementwithHandles
thisRegisters the handles that can be used to drag the element.
any[]thiswithPreviewTemplate
thisRegisters the template that should be used for the drag preview.
DragPreviewTemplate<any> | nullTemplate that from which to stamp out the preview.
thiswithPlaceholderTemplate
thisRegisters the template that should be used for the drag placeholder.
DragHelperTemplate<any> | nullTemplate that from which to stamp out the placeholder.
thiswithRootElement
thisSets an alternate drag root element. The root element is the element that will be moved as the user is dragging. Passing an alternate root element is useful when trying to enable dragging on an element that you might not have access to.
anythiswithBoundaryElement
thisElement to which the draggable's position will be constrained.
anythiswithParent
thisdispose
voidRemoves the dragging functionality from the DOM element.
voidisDragging
booleanChecks whether the element is currently being dragged.
booleanreset
voidResets a standalone drag item to its initial position.
voidresetToBoundary
voidResets drag item to end of boundary element.
voiddisableHandle
voidSets a handle as disabled. While a handle is disabled, it'll capture and interrupt dragging.
HTMLElementHandle element that should be disabled.
voidenableHandle
voidEnables a handle, if it has been disabled.
HTMLElementHandle element to be enabled.
voidwithDirection
thisSets the layout direction of the draggable item.
DirectionthisgetFreeDragPosition
Readonly<Point>Gets the current position in pixels the draggable outside of a drop container.
Readonly<Point>setFreeDragPosition
thisSets the current position in pixels the draggable outside of a drop container.
thiswithPreviewContainer
thisSets the container into which to insert the preview element.
anyContainer into which to insert the preview.
this