Class: Lens.Components.Draggable

Draggables are elements that can be moved and (optionally) rotated and scaled using touch and pinch-to-zoom.

Lens.Components.Draggable(el, multitouch) Components/draggable.js, line 19

Makes an element draggable.

Argument Type Attributes Description
el string | DOMElement | jQuery

Draggable element. Can be a CSS selector, a DOM element, or a jQuery object.

multitouch boolean <optional>

If true, allows resizing and rotation with two fingers. Defaults to true.

Instance Properties

enabled: Boolean

Whether this Draggable is enabled.

Instance Methods

disable() Components/draggable.js, line 66

Disables the draggable. The draggable will no longer move when touched.

enable() Components/draggable.js, line 58

Enables the draggable. Draggables start out enabled, so you only need to call this if you've disabled the Draggable with disable.

setPosition(newX, newY) Components/draggable.js, line 112

Set the x, y position of the draggable.

Argument Type Attributes Description
newX Number <optional>

New x position.

newY Number <optional>

New y position.

updated(onUpdateCallback) Components/draggable.js, line 78

Registers a callback to be run when the component is dragged. onUpdateCallback is called once per touch move event with the new position.

Argument Type Attributes Description
onUpdateCallback function <optional>

Callback called with onUpdateCallback(x, y, el).