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);


Constructor Description
L.Draggable(<HTMLElement> el, <HTMLElement> dragHandle?, <Boolean> preventOutline) Creates a Draggable object for moving el when you start dragging the dragHandle element (equals el itself by default).


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).


Event Data Description
down Event Fired when a drag is about to start.
dragstart Event Fired when a drag starts
predrag Event Fired continuously during dragging before each corresponding update of the element's position.
drag Event Fired continuously during dragging.
dragend DragEndEvent Fired when the drag ends.


Method Returns Description

Enables the dragging ability


Disables the dragging ability

Method Returns Description
on(<String> type, <Function> fn, <Object> context?) this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

on(<Object> eventMap) this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

off(<String> type, <Function> fn?, <Object> context?) 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 on, you must pass the same context to off in order to remove the listener.

off(<Object> eventMap) this

Removes a set of type/listener pairs.

off() this

Removes all listeners to all events on the object.

fire(<String> type, <Object> data?, <Boolean> propagate?) 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(<String> type) Boolean

Returns true if a particular event type has any listeners attached to it.

once() this

Behaves as on(…), except the listener will only get fired once and then removed.

addEventParent(<Evented> obj) this

Adds an event parent - an Evented that will receive propagated events

removeEventParent(<Evented> obj) this

Removes an event parent, so it will stop receiving propagated events

addEventListener() this

Alias to on(…)

removeEventListener() this

Alias to off(…)

clearAllEventListeners() this

Alias to off()

addOneTimeEventListener() this

Alias to once(…)

fireEvent() this

Alias to fire(…)

hasEventListeners() Boolean

Alias to listens(…)

Props Wrld.Prop
Themes Wrld.themes
Heatmaps Wrld.Heatmap
Events Event objects
Services (Optional) WrldPoiApi