diff options
Diffstat (limited to 'debian/missing-sources/leaflet.js/map/handler/Map.DoubleClickZoom.js')
-rw-r--r-- | debian/missing-sources/leaflet.js/map/handler/Map.DoubleClickZoom.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/debian/missing-sources/leaflet.js/map/handler/Map.DoubleClickZoom.js b/debian/missing-sources/leaflet.js/map/handler/Map.DoubleClickZoom.js new file mode 100644 index 0000000..c105e8e --- /dev/null +++ b/debian/missing-sources/leaflet.js/map/handler/Map.DoubleClickZoom.js @@ -0,0 +1,55 @@ +import {Map} from '../Map'; +import {Handler} from '../../core/Handler'; + +/* + * L.Handler.DoubleClickZoom is used to handle double-click zoom on the map, enabled by default. + */ + +// @namespace Map +// @section Interaction Options + +Map.mergeOptions({ + // @option doubleClickZoom: Boolean|String = true + // Whether the map can be zoomed in by double clicking on it and + // zoomed out by double clicking while holding shift. If passed + // `'center'`, double-click zoom will zoom to the center of the + // view regardless of where the mouse was. + doubleClickZoom: true +}); + +export var DoubleClickZoom = Handler.extend({ + addHooks: function () { + this._map.on('dblclick', this._onDoubleClick, this); + }, + + removeHooks: function () { + this._map.off('dblclick', this._onDoubleClick, this); + }, + + _onDoubleClick: function (e) { + var map = this._map, + oldZoom = map.getZoom(), + delta = map.options.zoomDelta, + zoom = e.originalEvent.shiftKey ? oldZoom - delta : oldZoom + delta; + + if (map.options.doubleClickZoom === 'center') { + map.setZoom(zoom); + } else { + map.setZoomAround(e.containerPoint, zoom); + } + } +}); + +// @section Handlers +// +// Map properties include interaction handlers that allow you to control +// interaction behavior in runtime, enabling or disabling certain features such +// as dragging or touch zoom (see `Handler` methods). For example: +// +// ```js +// map.doubleClickZoom.disable(); +// ``` +// +// @property doubleClickZoom: Handler +// Double click zoom handler. +Map.addInitHook('addHandler', 'doubleClickZoom', DoubleClickZoom); |