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 L.DomUtil.setPosition
.
Usage example
var draggable = new L.Draggable(elementToDrag);
draggable.enable();
Constructor
Constructor | Description |
---|---|
L.Draggable( |
Creates a Draggable object for moving el when you start dragging the dragHandle element (equals el itself by default). |
Options
Option | Type | Default | Description |
---|---|---|---|
clickTolerance |
Number
| 3 |
The max number of pixels a user can shift the mouse pointer during a click for it to be considered a valid click (as opposed to a mouse drag). |
Events
Event | Data | Description |
---|---|---|
down
| ||
dragstart
| ||
predrag
| ||
drag
| ||
dragend
|
Methods
Method | Returns | Description |
---|---|---|
enable() |
|
Enables the dragging ability |
disable() |
|
Disables the dragging ability |
Method | Returns | Description |
---|---|---|
on( |
this |
Adds a listener function ( |
on( |
this |
Adds a set of type/listener pairs, e.g. |
off( |
this |
Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to |
off( |
this |
Removes a set of type/listener pairs. |
off() |
this |
Removes all listeners to all events on the object. |
fire( |
this |
Fires an event of the specified type. You can optionally provide an data object — the first argument of the listener function will contain its properties. The event might can optionally be propagated to event parents. |
listens( |
Boolean |
Returns |
once(…) |
this |
Behaves as |
addEventParent( |
this |
Adds an event parent - an |
removeEventParent( |
this |
Removes an event parent, so it will stop receiving propagated events |
addEventListener(…) |
this |
Alias to |
removeEventListener(…) |
this |
Alias to |
clearAllEventListeners(…) |
this |
Alias to |
addOneTimeEventListener(…) |
this |
Alias to |
fireEvent(…) |
this |
Alias to |
hasEventListeners(…) |
Boolean |
Alias to |