JavaScript/jQuery Draggable API

Draggable is a user interface utility that allows widget elements to be dragged and dropped.

import Draggable from "devextreme/ui/draggable"
Type:

Object

Options

This section describes options that configure the Draggable widget's contents, behavior, and appearance.

Name Description
autoScroll

Enables automatic scrolling while dragging an item beyond the viewport.

boundary

Specifies a DOM element that limits the dragging area.

clone

Allows a user to drag clones of items instead of actual items.

container

Specifies a custom container in which the draggable item should be rendered.

cursorOffset

Specifies the cursor offset from the dragged item.

data

A container for custom data.

dragComponent

An alias for the dragTemplate property specified in React. Accepts a custom component. Refer to Using a Custom Component for more information.

dragDirection

Specifies the directions in which an item can be dragged.

dragRender

An alias for the dragTemplate property specified in React. Accepts a rendering function. Refer to Using a Rendering Function for more information.

dragTemplate

Specifies custom markup to be shown instead of the item being dragged.

elementAttr

Specifies the attributes to be attached to the widget's root element.

group

Allows you to group several widgets, so that users can drag and drop items between them.

handle

Specifies a CSS selector (ID or class) that should act as the drag handle(s) for the item(s).

height

Specifies the widget's height.

onDisposing

A function that is executed before the widget is disposed of.

onDragEnd

A function that is called when drag gesture is finished.

onDragMove

A function that is called every time a draggable item is moved.

onDragStart

A function that is called when the drag gesture is initialized.

onInitialized

A function used in JavaScript frameworks to save the widget instance.

onOptionChanged

A function that is executed after a widget option is changed.

rtlEnabled

Switches the widget to a right-to-left representation.

scrollSensitivity

Specifies the distance in pixels from the edge of viewport at which scrolling should start. Applies only if autoScroll is true.

scrollSpeed

Specifies the scrolling speed when dragging an item beyond the viewport. Applies only if autoScroll is true.

width

Specifies the widget's width.

See Also

Methods

Methods of the DomComponent object.

Name Description
beginUpdate()

Prevents the widget from refreshing until the endUpdate() method is called.

defaultOptions(rule)

Specifies the device-dependent default configuration options for this component.

dispose()

Disposes of all the resources allocated to the Draggable instance.

element()

Gets the root widget element.

endUpdate()

Refreshes the widget after a call of the beginUpdate() method.

getInstance(element)

Gets the instance of a widget found using its DOM node.

instance()

Gets the widget's instance. Use it to access other methods of the widget.

off(eventName)

Detaches all event handlers from a single event.

off(eventName, eventHandler)

Detaches a particular event handler from a single event.

on(eventName, eventHandler)

Subscribes to an event.

on(events)

Subscribes to events.

option()

Gets all widget options.

option(optionName)

Gets the value of a single option.

option(optionName, optionValue)

Updates the value of a single option.

option(options)

Updates the values of several options.

resetOption(optionName)

Resets an option to its default value.

Events

This section describes events raised by the Draggable widget.

Name Description
disposing

Raised before the widget is disposed of.

dragEnd

Raised when drag gesture is finished.

dragMove

Raised every time a draggable item is moved.

dragStart

Raised when drag gesture is initialized.

initialized

Raised only once, after the widget is initialized.

optionChanged

Raised after a widget option is changed.

See Also