You are viewing an older version of Mapbox.js. Check out v3.1.1 for the latest.

Draggable

A class for making DOM elements draggable (including touch support). Used internally for map and marker dragging. Only works for elements that were positioned with DomUtil#setPosition

var draggable = new L.Draggable(elementToDrag);
draggable.enable();

Creation

Creation Description
new L.Draggable( <HTMLElement> element, <HTMLElement> dragHandle? ) Creates a Draggable object for moving the given element when you start dragging the dragHandle element (equals the element itself by default).

Events

You can subscribe to the following events using these methods.

Event Data Description
dragstart Event Fired when the dragging starts.
predrag Event Fired continuously during dragging before each corresponding update of the element position.
drag Event Fired continuously during dragging.
dragend Event Fired when the dragging ends.

Methods

Method Returns Description
enable() - Enables the dragging ability.
disable() - Disables the dragging ability.