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[] | undefined
Class to be added to the preview element.
scale
number
If 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
boolean
Whether starting to drag this element is disabled.
disabled
boolean
beforeStarted
any
Emits as the drag sequence is being prepared.
started
any
Emits when the user starts dragging the item.
released
any
Emits when the user has released a drag item, before any animations have started.
ended
any
Emits when the user stops dragging an item in the container.
entered
any
Emits when the user has moved the item into a new container.
exited
any
Emits when the user removes the item its container by dragging it into another container.
dropped
any
Emits 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
T
Arbitrary data that can be attached to the drag item.
constrainPosition
((userPointerPosition: Point, dragRef: DragRef<any>, dimensions: DOMRect, pickupPositionInElement: Point) => Point) | undefined
Function 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
HTMLElement
Returns the element that is being used as a placeholder while the current element is being dragged.
HTMLElement
getRootElement
HTMLElement
Returns the root draggable element.
HTMLElement
getVisibleElement
HTMLElement
Gets the currently-visible element that represents the drag item. While dragging this is the placeholder, otherwise it's the root element.
HTMLElement
withHandles
this
Registers the handles that can be used to drag the element.
any[]
this
withPreviewTemplate
this
Registers the template that should be used for the drag preview.
DragPreviewTemplate<any> | null
Template that from which to stamp out the preview.
this
withPlaceholderTemplate
this
Registers the template that should be used for the drag placeholder.
DragHelperTemplate<any> | null
Template that from which to stamp out the placeholder.
this
withRootElement
this
Sets 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.
any
this
withBoundaryElement
this
Element to which the draggable's position will be constrained.
any
this
withParent
this
dispose
void
Removes the dragging functionality from the DOM element.
void
isDragging
boolean
Checks whether the element is currently being dragged.
boolean
reset
void
Resets a standalone drag item to its initial position.
void
disableHandle
void
Sets a handle as disabled. While a handle is disabled, it'll capture and interrupt dragging.
HTMLElement
Handle element that should be disabled.
void
enableHandle
void
Enables a handle, if it has been disabled.
HTMLElement
Handle element to be enabled.
void
withDirection
this
Sets the layout direction of the draggable item.
Direction
this
getFreeDragPosition
Readonly<Point>
Gets the current position in pixels the draggable outside of a drop container.
Readonly<Point>
setFreeDragPosition
this
Sets the current position in pixels the draggable outside of a drop container.
this
withPreviewContainer
this
Sets the container into which to insert the preview element.
any
Container into which to insert the preview.
this