mnisvdn / Leaflet.DraggableEnhancer

A tiny enhancer of the L.Draggable class to handle cases where one of the map parents prevents event propagation which results in map panning not working

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Leaflet.DraggableEnhancer

This plugin "enhances" the default L.Draggable class.
By default, the L.Draggable class is instanciated to allow dragging some objects around, like L.Map (which results in panning action in this case).

The fact is, the L.Draggable binds the events related to drag (mousedown, mouseup, mousemove, ...) to the main document root, which can cause problem if your map has to be instanciated within a <div> you do not master, and has an event.stopPropagation() executed with an handler bound to the mousemove event for example.
The result is, as long as your mouse will be over this <div>, the map panning won't work.

L.Draggable Issue

This plugin fixes this issue, and also takes care of handling other classes relying on L.Draggable, such as L.Map.BoxZoom.

It can also be found here, from from the official Leaflet Plugins repository, under the #Events category.

Tested only with Leaflet 1.0+
Goes untested with previous versions 0.7-

The minified version for production can found in the dist folder.
You can find source code in both ES5 and ES6.

About

A tiny enhancer of the L.Draggable class to handle cases where one of the map parents prevents event propagation which results in map panning not working


Languages

Language:JavaScript 100.0%