Legacy
Mapbox.js is no longer in active development. To learn more about our newer mapping tools see Mapbox GL JS.
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(
|
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. |